Post radiobuttons (forms) using lwp-useragent

R

Rubel Kanubel

Hi!

I've created a script that automatically logs into a site and fills
out a form. I'm using the LWP::Useragent module. The first form (the
login form) is no problem getting through. Examplified by the
following:

<code>

my $req = POST 'http://www.acme.com/login.php', [ name => 'john', pass
=> 'password' ];
my $res = $ua->request($req);

</code>

here the "name" and "pass" parameters represents textfield form
elements. The second form I'm trying to send includes radio button
form elements. But it doesnt seem like I can pass parameters like
above for these elements.

The radio button name is "rad_query", and its possible values are
"alt_1", "alt_2" and "alt_3".. but the following does not work

<code>

my $req = POST 'http://www.acme.com/login.php', [ rad_query" => 'alt
1' ];
my $res = $ua->request($req);

</code>

I know that radio buttons in php is represented as an array.. but I'm
not sure if this is the same in perl.. so I have a problem: How do I
pass radio button form elements by using LWP::Useragent.

Any answers, comments, ideas etc. would be very much appreciated.
Thanks!


/Regards Rubel Kanubel
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) (Rubel Kanubel) wrote in
<code>

my $req = POST 'http://www.acme.com/login.php', [ rad_query" => 'alt
1' ];
my $res = $ua->request($req);

I was about to point out that you wanted 'alt_1' but your code says either
'alt 1' or "alt\n1", but then I noticed that the above code can't possibly
work anyhow.

Please post your real code by copy/paste instead of re-typing it.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4mGYGPeouIeTNHoEQKcGQCg/VAijSzMYZ/6CY/ggRMXudo3BYYAoLNO
bdLe5OTS6Rjm1fBqgMItn0Bo
=RKMH
-----END PGP SIGNATURE-----
 
R

Rubel Kanubel

<tea_spoon>

$req = POST 'http://www.acme.com/login.php', [ rad_query => 'alt_1' ];
$res = $ua->request($req);

</tea_spoon>


Please point out exactly what you mean by "I was about to point out
that you wanted 'alt_1'". FYI, this is just an example of the code
that I'm executing to post form elements. The above two statements
illustrates my attempt (that fails) to post a radio button form
element. I'm sorry for the mis-spellings, but you should be able to
make out for yourself the problem without getting picky about it. The
question is: how can one post radio button form elements by using the
LWP::Useragent module.



Rubel

Eric J. Roode said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) (Rubel Kanubel) wrote in
<code>

my $req = POST 'http://www.acme.com/login.php', [ rad_query" => 'alt
1' ];
my $res = $ua->request($req);

I was about to point out that you wanted 'alt_1' but your code says either
'alt 1' or "alt\n1", but then I noticed that the above code can't possibly
work anyhow.

Please post your real code by copy/paste instead of re-typing it.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4mGYGPeouIeTNHoEQKcGQCg/VAijSzMYZ/6CY/ggRMXudo3BYYAoLNO
bdLe5OTS6Rjm1fBqgMItn0Bo
=RKMH
-----END PGP SIGNATURE-----
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) (Rubel Kanubel) wrote in
<tea_spoon>

$req = POST 'http://www.acme.com/login.php', [ rad_query => 'alt_1' ];
$res = $ua->request($req);

</tea_spoon>


Please point out exactly what you mean by "I was about to point out
that you wanted 'alt_1'".

Sure. You said that the possible values of the radio button input were
"alt_1", "alt_2", etc, but the code that you posted had: [ rad_query" =>
'alt
1' ]. Now, the first thing that occurred to me was that your program had
a simple typo in it, and you had a mismatch between the value that the
form required ("alt_1") and the value your program was supplying ("alt
1").

Then I saw that the line had a syntax error in it. That led me to
believe that you had not copy/pasted the code, but instead had retyped
it, and then all bets are off. If you mistyped the ", you could just as
easily have mistyped the CGI value, and God knows what else. How can
anyone help you debug your code if you don't post it, but instead post
something that is *similar* to your code?

FYI, this is just an example of the code
that I'm executing to post form elements. The above two statements
illustrates my attempt (that fails) to post a radio button form
element.

So even your re-posting above isn't the code that is the problem?
I'm sorry for the mis-spellings, but you should be able to
make out for yourself the problem without getting picky about it.

I appreciate your confidence in my abilities, but debugging code that I
can't see is not among my abilities.
The
question is: how can one post radio button form elements by using the
LWP::Useragent module.

It looks like you're doing everything mostly correct. Obviously,
something minor is amiss, and nobody here is going to find it unless you
post a short but working program that illustrates the problem.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4nd8GPeouIeTNHoEQIPPwCgnKT43JJVcAmbbw/qwcPqXYypDuYAoILF
5BlE4I+LgizjSlFcmYCpWl9u
=NVot
-----END PGP SIGNATURE-----
 
T

Tad McClellan

Rubel Kanubel said:
Please point out exactly what you mean by "I was about to point out
that you wanted 'alt_1'".


Your problem specification said so, but your code did not say so.

I'm sorry for the mis-spellings, but you should be able to
make out for yourself the problem without getting picky about it.


Computers are picky.

It is likely their pickiness that is the cause of your problem.

If you don't get picky about what instructions you are giving to
the machine, then figuring out why the machine isn't doing what
you want it to do will take a Really Long Time.


There are thousands of people around the world reading what you
write. It is common courtesy to take a bit of care to not lead
them on a wild goose chase in code that does not even exist.

question is: how can one post radio button form elements by using the
LWP::Useragent module.


Show us the code if you want us to debug the code.



[ snip Text Over Full-quote Under ]
 
A

Anno Siegel

Rubel Kanubel said:
<tea_spoon>

$req = POST 'http://www.acme.com/login.php', [ rad_query => 'alt_1' ];
$res = $ua->request($req);

</tea_spoon>


Please point out exactly what you mean by "I was about to point out
that you wanted 'alt_1'". FYI, this is just an example of the code
that I'm executing to post form elements. The above two statements
illustrates my attempt (that fails) to post a radio button form
element. I'm sorry for the mis-spellings, but you should be able to
make out for yourself the problem without getting picky about it.

Picky? You are the one wanting help, so it's your job to present
the problem in a comprehensible way. So long...

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top