Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Knocking Down Pesky JavaScript Popups from WWW::Mechanize

by hackdaddy (Hermit)
on Nov 11, 2003 at 20:41 UTC ( [id://306352]=perlquestion: print w/replies, xml ) Need Help??

hackdaddy has asked for the wisdom of the Perl Monks concerning the following question:

My dear fellow Perl hackers, I using WWW::Mechanize to automate internal corporate procedures that span several web sites. I have a web site that pops up a JavaScript generated window. When I attempt to use $agent->click( "Continue" ) or  $agent->submit(), WWW::Mechanize> cannot click or submit the form. Is there a way I can strip out the JavaScript to simply the submitting and automation of these popup windows? Can I call JavaScript from WWW::Mechanize or insert my own JavaScript into the content?

Any help/suggestions are greatly appreciated.

Thanks,

hackdaddy

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Blah Blah Update</title> <link rel=StyleSheet href="/tools/tools.css" type="text/css"> <script language="JavaScript" type="text/javascript"> <!-- //--> </script> </head> <html><body bgcolor="#cccccc"> <table align="center" valign="middle"> <tr><td align="center" valign="top" height="50" width="300"><p>Blah Bl +ah Updated</p></td></tr> <tr><td align="center" valign="bottom"><form name=searchForm method="g +et" action="/tools/update"> <input type="button" value="Continue" onClick="opener.location.reload( +);window.close();"> </form></td></tr> </table> </body></html>

Replies are listed 'Best First'.
Re: Knocking Down Pesky JavaScript Popups from WWW::Mechanize
by perrin (Chancellor) on Nov 11, 2003 at 21:39 UTC
    Just have Mechanize call the URL that is normally opened by JavaScript, and then proceed as usual. Basically, figure out what the JavaScript would do and do it yourself in your Perl code.
Re: Knocking Down Pesky JavaScript Popups from WWW::Mechanize
by hardburn (Abbot) on Nov 11, 2003 at 21:01 UTC

    Look on CPAN for JavaScript::. There are modules out there that can execute JavaScript, though I haven't personally used any of them.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://306352]
Approved by Grygonos
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-20 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found