Gossamer Forum
Home : General : Perl Programming :

form submission

Quote Reply
form submission
I am doing a research project on airline pricing, and I am trying to automatically query the american airlines website for prices. The search form I'm using is at http://www.aa.com/...ml?anchorEvent=false. The action field of the form is "/apps/reservations/RTripSearchFlights.jhtml?_DARGS=/apps/reservations/RTripSearchFlights.jhtml" So, after determining all the name/value pairs, I encode them GET style into this url:


http://www.aa.com/apps/reservations/RTripSearchFlights.jhtml?_DARGS=/apps/reservations/RTripSearchFlights.jhtml&tripType=roundTrip&_D:tripType=%20&currentCalForm=dep&_D:currentCodeForm=&origin=LAX&_D:origin=%20&destination=DFW&_D:destination=%20&departureMonth=9&_D:departureMonth=%20&departureDay=3&_D:departureDay=%20&departureTime=4&_D:departureTime=%20&returnMonth=9&_D:returnMonth=%20&returnDay=10&_D:returnDay=%20&returnTime=8&_D:returnTime=%20&numAdultPassengers=1&_D:numAdultPassengers=%20&numChildPassengers=0&_D:numChildPassengers=%20&cabinClass=business&_D:cabinClass=%20&searchType=fare&_D:searchType=%20&displayCount=50&_D:displayCount=%20&maximumStops=N&_D:maximumStops=%20&carrier=AA&_D:carrier=%20&countryPointOfSale=US&_D:countryPointOfSale=%20

If I try to go to that URL, instead of search results, I get the search form back, with the values that I specified filled in.

Also, if I do the same thing with a perl script using POST encoded data, the same thing happens. Here's the script:

#!/usr/bin/perl -w

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();

my $req = POST 'http://www.aa.com/apps/reservations/RTripSearchFlights.jhtml?_DARGS=/apps/reservations/RTripSearchFlights.jhtml', [ tripType = 'roundTrip', _D:tripType = ' ', currentCalForm = 'dep', _D:currentCodeForm = '', origin = 'LAX', _D:origin = ' ', destination = 'DFW', _D:destination = ' ', departureMonth = '9', _D:departureMonth = ' ', departureDay = '3', _D:departureDay = ' ', departureTime = '4', _D:departureTime = ' ', returnMonth = '9', _D:returnMonth = ' ', returnDay = '10', _D:returnDay = ' ', returnTime = '8', _D:returnTime = ' ', numAdultPassengers = '1', _D:numAdultPassengers = ' ', numChildPassengers = '0', _D:numChildPassengers = ' ', cabinClass = 'business', _D:cabinClass = ' ', searchType = 'fare', _D:searchType = ' ', displayCount = '50', _D:displayCount = ' ', maximumStops = 'N', _D:maximumStops = ' ', carrier = 'AA', _D:carrier = ' ', countryPointOfSale = 'US', _D:countryPointOfSale = ' ' ];

$content = $ua->request($req)->as_string;
print $content;

All I can't think of is that somehow the location of the form handler is not what's in the action field, or that I need to do something more with the submit button inputs in the form...

Any ideas? I would GREATLY appreciate anyone's help.

Thanks.