Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: The age old JavaScript WWW::Mech scenario

by whakka (Hermit)
on Apr 29, 2009 at 21:44 UTC ( #760987=note: print w/ replies, xml ) Need Help??


in reply to The age old JavaScript WWW::Mech scenario

Without specifying which, mech automatically selects the first form; you need to select the second form on that url, so:

$mech->submit_form( form_number => 2, fields =>{ sess => "summer", course => $prefix, }, );
gives me something.

UPDATE:...and that something wasn't good.

I've always found it easier to debug form automation in WWW::Mechanize by doing one thing at a time. This works for me:

use WWW::Mechanize; use HTML::TokeParser; my $mech = WWW::Mechanize->new(cookie_jar => undef); $url="http://www.utsc.utoronto.ca/~registrar/scheduling/timetable"; $prefix = "ANT"; $mech->get($url); $mech->form_number(2); $mech->set_visible( [radio => 'summer'] ); # page default anyway $mech->select( 'course', $prefix ); $mech->click_button( name => 'submit' ); print $mech->content();

- clarified first sentence.


Comment on Re: The age old JavaScript WWW::Mech scenario
Select or Download Code
Re^2: The age old JavaScript WWW::Mech scenario
by trwww (Priest) on Apr 30, 2009 at 00:39 UTC

    UPDATE:...and that something wasn't good.

    You're probably just missing the button that needs clicked to send the form:

    $mech->submit_form( form_number => 2, fields =>{ sess => "summer", course => $prefix, }, button => 'submit', );

    That might work.

      Yep, that's probably more elegant. TMTOWTDI - to each his own :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://760987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-07-25 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls