l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
July 21: Defensive computing: Information security for individuals
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2001 Dec 30 16:59

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[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



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!