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' );

In reply to Re^2: trouble talking to html form using LWP by mhearse
in thread trouble talking to html form using LWP by mhearse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.