Hi all,
I have a perl script that fills submits a HTML form with METHOD POST and
input type file.
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder;
use HTTP::Request::Form;
use LWP::UserAgent;
use URI::URL;
# Upload the Website
my $url = url 'http://some host/navitune.html';
my $ua = new LWP::UserAgent;
my $res = $ua->simple_request(POST $url);
# Parse the website and extrach the Form
my $tb = new HTML::TreeBuilder->parse( $res->content);
my @forms = @{ $tb->extract_links('FORM') };
# The first Form
my $f = HTTP::Request::Form->new( $forms[0][1], $url );
$f->dump(); # Prints the extrachted Form on the STDOUT
# Fill and Send the Form
$f->field( 'wav_file', 'st11.wav' ); # wav_file is the name of the
input
field and st11.wav is the file
to be
Uploaded
my $response = $ua->request($f->press('submit'));
# Response from the Serverside
print $response->as_string;
The webserver should send me a list of macthes but i get a response saying :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a
href="http://somemhost/cgi-bin/navitune_web?2+input2.wav">here</a>.</p>
</body></html>
I think there is some problem with redirect, because when I go to:
http://somemhost/cgi-bin/navitune_web?2+input2.wav
i have the list there, but I would like to store th elist straight away in a
file.
I have tried using methods from LWP::UserAgent like simple_request and
redirect_ok but it did not work.
I would be gratefull for anyhelp, thanks for ur time
nandita
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- Re: LWP::UserAgent Nandita Shenvi
- Re: LWP::UserAgent Rob Dixon