Forum Moderators: coopster & phranque

Message Too Old, No Replies

Form submission

         

Ellen_147

11:26 am on Sep 11, 2005 (gmt 0)

10+ Year Member



Hi everyone,
I found some examples using LWP::UserAgent to submit a list of parameters to a login page or search engine. An result page will be printed out or saved in a html page.

But none of them is working. What's wrong? Please help.

#!/usr/bin/perl -w

use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent('Mozila/4.0 (....));

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

my $req = POST 'http://www.bababa.cgi',
["parameter1" => "value","parameter2" => "value"];

$request = $ua->request($req);
$content = $request->content;

leunga

1:10 pm on Sep 11, 2005 (gmt 0)

10+ Year Member



Would you please include error messages, so that we could understand what is the underlining problem?

One possbility is due to "proxy", but I am not sure whether it is specific to your problem.

KevinADC

9:25 pm on Sep 11, 2005 (gmt 0)

10+ Year Member



are the modules you are trying to use installed on the server you are trying to use them on?

LWP::UserAgent
HTTP::Request::Common

also, you have a syntax error in your script which will definetly kill it:

$ua->agent('Mozila/4.0 (....));

there is only one single quote in the argument, should be:

$ua->agent('Mozila/4.0');

I'm not sure what the (....) is for in your code, maybe that was just an example you found, which indicates that it could be filled in with more arguments if needed, it's like:

sub do_this {
....
}

where the .... just means that's where the code you will use goes.

Ellen_147

3:59 am on Sep 12, 2005 (gmt 0)

10+ Year Member



I wanted to print out the result stored in $content, but nothing came out.

(...) is just an example.

I used
$ua->agent('Mozila/4.0 (compatible; MSIE 5.5; Windows 98)');
Am I right?

KevinADC

5:34 am on Sep 12, 2005 (gmt 0)

10+ Year Member




I wanted to print out the result stored in $content, but nothing came out.

(...) is just an example.

I used
$ua->agent('Mozila/4.0 (compatible; MSIE 5.5; Windows 98)');
Am I right?

That should be OK. You can put almost anything there you want I believe.

PS: Mozilla is spelled with two L's.

Ellen_147

8:58 am on Sep 12, 2005 (gmt 0)

10+ Year Member



But the code is not working.
$content should contain something or a result html page.

I got nothing in there when I printed out $content.

What's wrong with it?

Ellen_147

11:23 am on Sep 12, 2005 (gmt 0)

10+ Year Member



I send a submission to a search engine.
There is the error message:

<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</HEAD><BODY BGCOLOR='#FFFFFF'>
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<!-- comment here -->
<H1><IMG SRC="../images/88x31_logo_white.gif" WIDTH="88" HEIGHT="31" ALIGN="TOP"
BORDER="0" NATURALSIZEFLAG="3"> Mascot Search</H1>
The following error has occured getting your search details:<BR>
No boundary= in CONTENT_TYPE (application/x-www-form-urlencoded) [M00055]<BR>
Have you tried the <A HREF="browser.pl">browser compatibility</A> test page?<BR>

Please help.

KevinADC

12:37 am on Sep 13, 2005 (gmt 0)

10+ Year Member



sorry, I am not familiar with the LWP modules, but I suggest you try GET instead of POST. Read the HTTP::Request::Common documentation too.