On Thu, Jun 27, 2002 at 10:20:29PM +0200, David Suna wrote:
> I would like to automate the process of having a user visit a web
> site, fill in a form, submit the form and receive results.
>
> What would be the best technology to choose to implement this? I
> have thought of using either Java or Python to create a client
> application that will open a web site, receive the HTTP code,
> respond with the appropriate response and receive the results as
> HTTP code. As I have no experience with either language which
> would be the easier to use to implement this in a short time frame?
>
> Ideally I would like the program to look something like the pseudo
> code below:
> Document = open("http://some.url.here");
> Form = Document.GetForm("form name");
> Field = Form.GetField("field name");
> Field.setValue("new value");
> Form.submit();
> Results = ReceiveResults();
Try Perl with LWP and HTML::Form. LWP (LWP::UserAgent along with
HTTP::Request, HTTP::Response and friends) will do the HTTP requests
for you, while HTML::Form will parse HTML forms, so that you could
later fill them in a fashion such as:
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request(GET => "http://initial_form");
my $response = $ua->request($request);
if ($response->is_success) {
my $html_data = $response->content;
my @forms = HTML::Form->parse($html_data, $base_uri)
my $first_form = $forms[0];
if ($first_form) {
$first_form->value("first_name", "John Smith");
$request = $first_form->click("submit_button");
$response = $ua->request($request);
if ($response->is_success) {
print $response->content;
}
}
}
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]