Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WWW::Mechanize

0 views
Skip to first unread message

Nathan

unread,
Dec 18, 2009, 3:01:19 AM12/18/09
to
Hi,
is anyone familiar with this module?
I have a form with a radio button, any idea how do I click on it???

to be more precise,I have an HTML page, with a radio button, and a
submit button, how do I click / set the radio button??? (I managed to
click the submit button...)

gorjusborg

unread,
Dec 18, 2009, 9:19:20 AM12/18/09
to
I'm no Mech expert, but.. it is a pretty popular module.

You aren't wasting your time learning how to use it.
So 'perldoc WWW::Mechanize' is your friend...

That said....
Here's one way to choose a radio field value:

# (obviously not production code)
#
$mech->get("http://www.google.com");
$mech->form_number(1);
$mech->field('radiogroup_name', 'value you want to set');
$mech->click_button(number => 1);

This assumes you know the radio name, and that the form is the first
one in the page, as well as the submit button being the first button
in the form. That's a lot of assumptions, but assumptions keep code
simple! If you need a more general solution, you'll have to do more
inspection by accessing data objects through Mech.

Mech scripts can get prohibitively complicated if you don't know
anything about the HTML you may encounter.

.

0 new messages