Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

calling a javascript function from perl

by vinouspleasure (Initiate)
on Dec 25, 2008 at 05:45 UTC ( [id://732544]=perlquestion: print w/replies, xml ) Need Help??

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

first post, 3rd perl program, I have written code which parses a web page. I'd now like to crawl the site but navigation is accomplished via javascript:
<a href="" onClick="changePage(2); return false;">[2]</a>, <a href="" + onClick="changePage(3); return false;">[3]</a>
and so on. Here's the changePage function:
function changePage(page){ document.thisForm.theCurrentPage.value=page; document.thisForm.submit(); }
Is there a way for me to invoke the js changePage function directly and pass in a parameter?


Replies are listed 'Best First'.
Re: calling a javascript function from perl
by Anonymous Monk on Dec 25, 2008 at 06:09 UTC
      Thanks...I took a look at mechanize and recording before posting but hoped for something a little more direct. Automating the browser is an interesting idea but crawling is recursive while I would think automation assumes a determinate number of end states?
Re: calling a javascript function from perl
by petr999 (Acolyte) on Dec 25, 2008 at 15:08 UTC
    Once upon a time i was wondered how easy was to break through the javascript obfuscation to rip data from the web page with Which is the intreface to the stand-alone JS interpreter by Mozilla project. Of course the functionality should be additionally elaborated on DOM behavior imitation.But it does just what you ask: evaluates JS function as Perl function.
Re: calling a javascript function from perl
by imrags (Monk) on Dec 26, 2008 at 04:45 UTC
    Information can be found regarding similar problem ( i faced it) here: Win32::IE::Automation

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-07-14 01:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.