perloc perloc - 5 months ago 9
Javascript Question

How can I run a Javascript of a web page in Perl?

Possible Duplicate:

How can I use Perl to grab text from a web page that is dynamically generated with JavaScript?

I am interested in learning Perl and just started to write a web crawler in Perl. On the page that I crawled, there is a Javascript for giving vote to the page. It shows the vote of the current page, only if I click the voting stars. So during the crawling, I need to run the Javascript and learn the current voting of the page.

Do you have any suggestions or examples?



You would need to use module WWW::Scripter with WWW::Scripter::Plugin::JavaScript.



use strict;
use warnings;
use WWW::Scripter;

$w = new WWW::Scripter;
$w->use_plugin('JavaScript');  # packaged separately
$w->eval(' alert("Hello from JavaScript") ');
$w->content; # returns the HTML content, possibly modified by scripts