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

Hi,
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?

tia,

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 Javascript.pm. 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
    Njoi!
    Raghu