need help with HTTP::Request::Common

S

Some Guy

I'm trying to use HTTP::Request::Common, and can't get it to work.
Specifically, I'm trying to use it on
http://www.geocaching.com/seek/nearest.aspx?zip=asdf&dist=100 to get
geocaches by zipcode, using the following:

------------------------------------------

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Request::Common;


my $action = POST 'http://www.geocaching.com/seek/nearest.aspx?zip=asdf&dist=100',
[
'DropDownTaxonomy' => '9a79e6ce-3344-409c-bbe9-496530baf758',
'LocationPanel1:ddSearchType' => 'ZIP',
'LocationPanel1:OriginText' => '90210'
];

$action->header( 'User-Agent' => 'Mozilla/5.0' );

my $ua = LWP::UserAgent->new;
my $request = $ua->request( $action );

$request->is_success or die $request->status_line;

my $content = $request->content;


my $file = "tmp.txt";
open(FILE, ">$file") or die "Error opening file";
print FILE $content;
close(FILE);
 
P

perlmodule

The most likely reason is that you don't have all required fields in
your post request, such as:

LocationPanel1:btnLocale
 
T

Tad McClellan

Some Guy said:
I'm trying to use HTTP::Request::Common, and can't get it to work.


Why are you making a POST rather than a GET?

^^^^
^^^^

Where is that "asdf" zipcode anyway?



use LWP::Simple;

my $zip = '90210';
my $html = get 'http://www.geocaching.com/seek/nearest.aspx?'
. "zip=$zip&dist=100";


Works for me...
 
C

Chris Mattern

Tad said:
^^^^
^^^^

Where is that "asdf" zipcode anyway?

Near "xyzzy", I think.


--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
S

Some Guy

Tad McClellan said:
Why are you making a POST rather than a GET?


^^^^
^^^^

Where is that "asdf" zipcode anyway?




use LWP::Simple;

my $zip = '90210';
my $html = get 'http://www.geocaching.com/seek/nearest.aspx?'
. "zip=$zip&dist=100";


Works for me...

The thing is, I'm living in Canada, so our zip codes (postal codes)
are formatted differently, like A1B-2C3. I tried using a get and it
didn't work, but I just figured out now that if I put a space in the
postal code where the hyphen is, it accepts it. Thanks for the
response!
 
T

Tad McClellan

Just to be clear. Your problem had nothing to do with that module.

(this thread was an XY-problem)

The thing is, I'm living in Canada, so our zip codes (postal codes)
are formatted differently, like A1B-2C3.


Then why did you give us 2 examples that were not formatted that way?

I just figured out now that if I put a space in the
postal code where the hyphen is, it accepts it.


Just like when you use the search form normally via a browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top