Forum Moderators: coopster & phranque

Message Too Old, No Replies

Help with automating form submission with Perl

auto form submission with Perl

         

mimi_Cathy

3:12 pm on Aug 4, 2003 (gmt 0)

10+ Year Member



Hi,

I want to post a form including id, password and other data to
a url with Perl/CGI.

I follow the example below:

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod',
[ module => 'DB_File', readme => 1 ];
$content = $ua->request($req)->as_string;

But it doesn't work.

The reponse is: "HTTP/1.1 500 Internal Server Error"

Does anyone have any idea what is wrong with it.

Any help will be appricated.

Thanks for your time.

Mimi

moltar

3:17 pm on Aug 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does error log say?

This code works fine on my machine.

Are you sure you have all the required modules installed?

mimi_Cathy

3:54 pm on Aug 4, 2003 (gmt 0)

10+ Year Member



Hi, Moltar

Thank you for the reply.

The example code works fine for me as well. But after I put in my own fields, it stop working. If I type in the url and all the pass in fields(e.g. [myusrl?id=myid&password=mypassword&name1=myname1&address=myaddress),...] it will work.

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST 'my url',
[ id => $id, password => $password, name1=>$name1, name2=>$name2, address = $address];
$content = $ua->request($req)->as_string;

The error log says that: "HTTP/1.1 500 Internal Server Error".

I believe that I've got all modules required otherwise the example code wouldn't work.

How could I find out what url are actually called and together with their parameters?

I used warn("$req"), but it print out: "HTTP::Request=HASH(0x8e350c0)".

Thanks again

Mimi

moltar

4:12 pm on Aug 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are trying to post to the URL, you do need to pass the GET variables.

For example, you are posting to this URL: [myusrl?id=myid&password=mypassword&name1=myname1&address=myaddress...]

But instead you should be posint to just [myusrl...]

I don't think this could be a problem, but try it.

And what you showed here is not a log entry, this is what you see on the screen, but what does you error log file say?