> -----Original Message-----
> From: Luke Bakken [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, July 25, 2001 5:13 PM
> To: [EMAIL PROTECTED]
> Subject: USPS has me stumped!
> 
> 
> Hi all,
> 
> I'm tinkering with some of the libwww modules and trying to 
> get some information from the USPS web site.  Here's a simple 
> script to get a zip+4
> address:
> 
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;
> 
> $ua = LWP::UserAgent->new;
> 
> my $req = POST 'http://www.usps.gov/cgi-bin/zip4/zip4inq2',
>  [ 'Submit' => 'Process',
>    'Delivery Address' => '46 W 34TH AVE',
>    'Zip Code' => 99203 ];
> 
> print $ua->request($req)->as_string;
> 
> Every time I run this I get a 500 error, yet when I do the 
> same thing with lynx from my machine, it works fine.
> 
> Is the web site able to discern who is sending requests to 
> keep people from mass-querying their database?  I have tried 
> adding a $ua->agent('Mozilla/5.0'); line to no avail.
> 
> I have also used the cg-eye live service at www.htmlhelp.org 
> to diagnose the problem, but I still get the same 500 error 
> there (but no error otherwise).
> 
> Any ideas?
> Thanks,
> Luke

I got it to work by: 1) adding all the form fields, and 2) putting them in
the same order as they appear on the form. Not really sure why either of
these was necessary. Didn't change agent identifier at all.

   my $req = POST 'http://www.usps.gov/cgi-bin/zip4/zip4inq2',
   [
      'Firm' => '',
      'Urbanization' => '',
      'Delivery Address' => '46 W 34TH AVE',
      'Zip Code' => '99203', 
      'City' => '',
      'State' => '',
      'Submit' => 'Process',
   ];

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to