On Fri, Jan 10, 2003 at 12:51:45AM +0530, Sukrit wrote:

> Problem Overview
> - ----------------
> Somewhere on the world wide web, exists an asp page with the following
> form -
> <form action="rollresult.asp" method="POST" id="form1" name="form1" onSubmit="return 
>validate()" target="_top">

> 
> On entering a valid roll number and pressing enter, results for that number
> are displayed. Currently this has to be done manually, for say 120
> students. Very painful indeed.
> 
> 1 What i can manage
> - -------------------
> i can,
> 1.1 Generate valid numbers.
> 1.2 Extract information from an html page.
> 
> 2 What i need to know
> - ---------------------
> i need to know how to,
> 2.1 Enter info in a form at a particular url.
> 2.2 Save the resultant file on locally. (for 1.2 above)
> 

I see that you are a unix user (probably):

X-Mailer: VM 7.07 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid

Here's how I'd do it.

Using the lynx web browser I would go to the site of interest, enter some
information into the form , select the submit button and press =

This gives me some information about what is happening to the url
ie. what information is getting POSTed and what is getting GETed

then I'll use LWP::Simple to send appropriate requests and pop them in
a suitable file.

Here's something to do something similar (untested):

#!/usr/bin/perl -w
my $file="<output file name>";
open <FILE> $file;
use strict ;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req;
my $url="<url here>"
my $res;
my $request_string="<form of request string as ascertained through lynx with your data 
interpolated into it>";
$req = HTTP::Request->new(POST => $url);
$req->content_type('application/x-www-form-urlencoded');
$req->content($request_string);
$res = $ua->request($req);
my $result =  $res->as_string; # or other appropriate method as you desire.
print FILE $result;


or similar.  man lwpcook should tell you more.  I suspect that there
are mistakes in my code, but that should get you started.

Kieren

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to