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

This code works for me:

#!/usr/bin/perl use strict; use HTTP::Request::Common; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $url = q{http://cgmix.uscg.mil/PSIX/VesselSearch.aspx}; my $req = GET $url; my $res = $ua->request($req); my ($key) = $res->content() =~ m{name="__VIEWSTATE" value="([^"]+)"}; $req = POST $url, Content_Type => 'application/x-www-form-urlencoded', Content => [ VesselName => 'FLINTHORN', VesselNumber => '', VesselCallSign => '', VesselHull => '', DropDownListFlag => 'ALL', DropDownListService => 'ALL', VesselYear => '', CheckBoxOutService => '', Submit1 => 'Search', __VIEWSTATE => $key, ]; $res = $ua->request($req); print $res->content(); __END__

As you can see Content_Type => 'form_data' is one of mistakes

Replies are listed 'Best First'.
Re^4: trouble talking to html form using LWP
by mhearse (Chaplain) on Sep 05, 2007 at 11:26 UTC
    Thanks!!