[vox-tech] How to parse and submit a form in perl
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vox-tech] How to parse and submit a form in perl
- Subject: [vox-tech] How to parse and submit a form in perl
- From: "Jay" <jstrauss@bMAPSazillion.com>
- Date: Thu, 21 Dec 2000 19:54:58 -0800
Sorry to post a perl question, but I know there are some of you out there who
know perl.
I've been working on this all day and while I'm learning stuff I've got about 10
lines of code (and only 8 work) to show for my effort.
I swear I'm RTFMs, perldoc, searching maillists... but things are not documented
for the unfamiliar (i.e. beginner, i.e stupid).
(since I'm drowning) Maybe it will be easier if explain what I want to do.
I want to go to a web page, I'll supply the URL as command line arg, it will
look like:
https://some.securesite.com/cgi/purchasepage.asp?product_id=700314996C26550&prod
uct_code='
This will return a page composed of 3 forms, I'm concerned with the 2nd form. On
this form there are a bunch of hidden input fields and 3 fields the user is
supposed to enter (1st is text field (Quantity), second is a select list
(state), 3rd is a radio button (preferred shipper (UPS, Fedex)), and a submit
button.
I want to set the quantity, state, and shipper, and submit the form (along with
all the hidden values). Then retrieve then next form that is returned (from the
submission of the previous form) and start the process over (but with different
inputs) working my way all the way thru the purchase process.
I've been looking at HTML::Parser, HTML::Form, HTML::Tokeparser, they all seem
to do some of what I want. But I can't figure out how to use them.
Could someone point me in the right direction (maybe with some examples). I've
got this code so far (get ready to laugh):
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTML::Form;
# Extract the program name from the incarnation
# of the program
my @path = split(/\//,$0);
my $programName = $path[@path -1];
# Get website from command line
my $url = $ARGV[0];
my $uri =
URI->new('https://some.securesite.com/cgi/purchasePage.asp?product_id=700314996C
26550&product_code=');
my $ua = new LWP::UserAgent;
$ua->timeout(60);
$ua->agent("$programName/0.1 ". $ua->agent);
my $request = new HTTP::Request('GET' , $uri );
my $response = $ua->request($request);
# it works up till here #
# this stuff is new
my @forms = HTML::Form->parse($uri->path,$uri->host);
#print $forms[1]->action;
print $forms[1]->inputs;
exit(0);
Jay Strauss
jstrauss@bazillion.com
(h) 773.935.5326
(c) 312.617.0264
|