Shizzle has asked for the wisdom of the Perl Monks concerning the following question:
USPS.com recently made a change to their Zip Lookup program. I tried to automate a query with the following script:
#!/opt/gnu-irix/bin/perl use strict; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $ua = new LWP::UserAgent; my $url = 'http://www.usps.com/zip4/zip4_response.jsp'; my $data = [ 'Selection' => '1', 'address1' => $ARGV[0], 'address2' => '', 'city' => '', 'state' => '', 'zipcode' => $ARGV[1], 'Submit' => '' ]; $ua = new LWP::UserAgent; my $resp = $ua->request(POST $url, $data); if ($resp->is_success()) { print $resp->content(); } else { print "OOPS\n", $resp->as_string(); }
At the command prompt, I typed:
address.pl '1713 62nd Avenue' '20785'
And got this response:
OOPS HTTP/1.1 500 (Internal Server Error) Server Error Connection: close Date: Fri, 16 Aug 2002 15:20:52 GMT Server: Netscape-Enterprise/6.0 Content-Length: 305 Content-Type: text/html Client-Date: Fri, 16 Aug 2002 15:20:45 GMT Client-Peer: 56.0.78.66:80 Title: Server Error <HTML><HEAD><TITLE>Server Error</TITLE></HEAD> <BODY><H1>Server Error</H1> This server has encountered an internal error which prevents it from f +ulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log. </BODY></HTML>
I urgently need an explanation for this. My initial thought is that LWP cannot interface with Java servlets (.jsp does indicate a java servlet, right?). Your feedback is greatly needed and appreciated.
|
|---|