Fellow Monks,

I'll be going on vacation soon and am trying to set up a script to ocassionaly get me a airfare quote. I've set up form params according to the page, but I cannot get past the second page in the process. I keep getting an error from the page saying that I incorrectly passed a value from the first page. Here's my code. Any help would be appreciated.

#!/usr/local/bin/perl use HTTP::Request::Common qw(POST); use HTTP::Request; use LWP::UserAgent; use HTTP::Cookies; use LWP::Debug '+'; use strict; my $DEBUG = 1; my $VERBOSE = 1; my $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); my $cookie_jar = HTTP::Cookies->new(); $ua->cookie_jar($cookie_jar); my $req = new HTTP::Request ( 'GET', 'http://www.aa.com' ); my $res = $ua->request($req); $cookie_jar->extract_cookies($res); my $content = $res->content; my $session_id = $content; $session_id =~ s/.*(jsessionid=.*?)".*/$1/gis; my $submit_url = "http://www.aa.com/apps/reservations/FlightSearch +Results.jhtml;$session_id"; my $ua = new LWP::UserAgent; $req = POST $submit_url, [ '_DARGS' => '/apps/modules/makeReservation.jhtml +.8', 'currentCalForm' => 'dep', 'currentCodeForm' => '', 'tripType' => 'roundTrip', '_D:tripType' => ' ', 'origin' => 'DFW', '_D:origin' => ' ', 'departureMonth' => '11', '_D:departureMonth' => ' ', 'departureDay' => '24', '_D:departureDay' => ' ', 'departureTime' => '1', '_D:departureTime' => ' ', 'departureYear' => '', 'destination' => 'LGA', '_D:destination' => ' ', 'returnMonth' => '12', '_D:returnMonth' => ' ', 'returnDay' => '3', '_D:returnDay' => ' ', 'returnTime' => '1', '_D:returnTime' => ' ', 'returnYear' => '', 'numAdultPassengers' => '2', '_D:numAdultPassengers' => ' ', 'numChildPassengers' => '0', '_D:numChildPassengers' => ' ', 'searchType' => 'schedule', '_D:searchType' => '', '/aa/travelinfo/SearchFlightsFormHandler.submit' => '', '_D:/aa/travelinfo/SearchFlightsFormHandler.submit' => ' ', ]; ## DEBUG THE HEADERS debug ( $req->content ); ## MAKE THE ACTUAL REQUEST $res = $ua->request($req); #$loc = $res->headers->header('location'); debug ( $res->content ) if $VERBOSE; ################ DEBUG FUCTION ####################################### +############################################ sub debug { if ($DEBUG) { my $spacer = '|' x 80; print "\n\n$spacer DEBUG $spacer\n"; print @_; print "\n$spacer <END>DEBUG $spacer\n"; } }

In reply to HTTP::Request Problem by ttcuberat

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.