开发者

How to analyze the markup of a web page after javascript processing within a script/from CLI?

I have been researching for the standard practice to analyze the markup of a web page after javascript processing within a script or from the command line, i.e. without any browser?

This needs to happen on a Linux environment. Are the are "installables" that would allow you to pass HTML markup including javascript and it would return the markup after simulating a standard browser request and all Javascript calls have been done?

If there are any Perl Modules you can think of than that would be of even more help.

I have been looking at https://developer.mozilla.org/en/SpiderMonkey and http://search.cpan.org/~mschilli/JavaScript-SpiderMonkey-0.12/SpiderMonkey.pm but I am not sure this would allow me to pass in a full HTML document in and get the processed version with all javascript DOM manipulations back?

Please let me know.

开发者_如何转开发Update, I figure it out

I figured it all out - this is what needs to be done:

#!/usr/bin/perl

use WWW::Scripter;
$w = new WWW::Scripter;

$w->use_plugin('JavaScript');
$w->get('http://www.google.com');
print $w->content(),"\n";


You have to use a browser, a new one like WWW::Scripter::Plugin::Javascript or an old one like WWW::Mechanize::Firefox


Maybe the solution could be headless browser like PhantomJS. Not a perl module, but very practical for front-end testing and automation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜