Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Post radiobuttons (forms) using lwp-useragent

Reply
Thread Tools

Post radiobuttons (forms) using lwp-useragent

 
 
Rubel Kanubel
Guest
Posts: n/a
 
      10-12-2003
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
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      10-12-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(Rubel Kanubel) wrote in
news: om:

> <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-----
 
Reply With Quote
 
 
 
 
Rubel Kanubel
Guest
Posts: n/a
 
      10-12-2003
<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" <> wrote in message news:<Xns941282AC4B3C9sdn.comcast@206.127.4.25>...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> (Rubel Kanubel) wrote in
> news: om:
>
> > <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-----

 
Reply With Quote
 
Eric J. Roode
Guest
Posts: n/a
 
      10-12-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(Rubel Kanubel) wrote in
news: om:

> <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-----
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      10-13-2003
Rubel Kanubel <> wrote:

> 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 ]

--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      10-13-2003
Rubel Kanubel <> wrote in comp.lang.perl.misc:
> <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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping through dataset outputting HTML radiobuttons Robert H ASP .Net 0 12-04-2003 11:02 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM
RadioButtons, get checked buttons and using GroupName property. Solveig Osk ASP .Net Web Controls 0 08-12-2003 11:37 AM
RadioButtons & DataGrid RB ASP .Net 0 08-11-2003 04:29 PM
Radiobuttons and textbox with autopost Sean ASP .Net 1 08-06-2003 12:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57