You all are correct, but this code still doesn't get the results:
#!/usr/bin/perl
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
use HTTP::Cookies;
use URI::Escape;
my $url = q{http://cgmix.uscg.mil/PSIX/VesselSearch.aspx};
my $ua = LWP::UserAgent->new();
$ua->cookie_jar( HTTP::Cookies->new(
'file' => '/home/matt/cookies.txt',
));
my $safe_key = uri_escape($key);
my $req = POST $url,
Content_Type => 'form_data',
Content => [
VesselName => 'FLINTHORN',
VesselNumber => '',
VesselCallSign => '',
VesselHull => '',
VesselYear => '',
CheckBoxOutService => '',
__VIEWSTATE => $safe_key, ];
my $res = $ua->request($req);print $res->content();
It is getting the correct cookie:
$VAR1 = bless( {
'_content' => 'VesselName=FLINTHORN&VesselNumber=&Ves
+selCallSign=&VesselHull=&VesselYear=&CheckBoxOutService=&__VIEWSTATE=
+SHORTKEYTOSAVESPACE',
'_uri' => bless( do{\(my $o = 'http://cgmix.uscg.mil/
+PSIX/VesselSearch.aspx')}, 'URI::http' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/5
+.65',
'content-type' => 'form_data',
'cookie' => '$Version=2; ASP.N
+ET_SessionId=xmtfq5nrirypi245hpi20e45; $Port="80"',
'content-length' => 126
}, 'HTTP::Headers' ),
'_method' => 'POST'
}, 'HTTP::Request' );
|