长期以来,我一直在尝试使用 python(2.4) 解析和运行 javascript 网页。不幸的是,我不能使用 qt,webkit,所以大多数基于 python 的无头浏览器都被排除在外。然而,我最近在 perl(使用 perl 5.8.8)中发现了 WWW::Scripter,它似乎也是 javascript 的脚本引擎。我还安装了运行它所需的 javascript 插件。
use WWW::Scripter;
$w = new WWW::Scripter;
$w->use_plugin('JavaScript'); # packaged separately
$w->get('some javascript website');
print $w->content;
好吧,它会打印出很多错误并最终终止,并且输出似乎与预期的相差无几。我尝试了 3-4 个站点,但结果相同。预期的输出是指从谷歌浏览器的检查元素中可以看到的源代码。知道我在使用 perl 脚本时做错了什么吗?其次,让javascript引擎运行以解析python2.4或perl(甚至ruby,约束不能使用qt)中的网站的任何快速替代方法希望我能提出我的问题而不会造成很多混乱。
编辑:前几行错误:
Day too big - 52263 > 24855
Sec too small - 52263 < 74752
Sec too big - 52263 > 11647
Day too big - 52263 > 24855
Sec too small - 52263 < 74752
Sec too big - 52263 > 11647
<></> at /usr/lib/perl5/site_perl/5.8.8/HTML/DOM/Element.pm line 320.
at /usr/lib/perl5/site_perl/5.8.8/HTML/DOM/Element.pm line 320.
HTML::DOM::Element::getAttribute('HTML::DOM::Element::Input=HASH(0xcc309f0)', 'checked') called at /usr/lib/perl5/site_perl/5.8.8/HTML/DOM/Element.pm line 379
HTML::DOM::Element::_attr('HTML::DOM::Element::Input=HASH(0xcc309f0)', 'checked') called at /usr/lib/perl5/site_perl/5.8.8/HTML/DOM/Element/Form.pm line 965
HTML::DOM::Element::Input::defaultChecked('HTML::DOM::Element::Input=HASH(0xcc309f0)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/DOM/Element/Form.pm line 975
HTML::DOM::Element::Input::checked('HTML::DOM::Element::Input=HASH(0xcc309f0)') called at /usr/lib/perl5/site_perl/5.8.8/JE.pm line 1719
JE::__ANON__('JE::Object::Proxy=REF(0xcb53f44)', undef) called at /usr/lib/perl5/site_perl/5.8.8/JE/Object.pm line 385
JE::Object::prop('JE::Object::Proxy=REF(0xcb53f44)', 'checked') called at /usr/lib/perl5/site_perl/5.8.8/JE/LValue.pm line 91
JE::LValue::get('JE::LValue=ARRAY(0xcc4eac8)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1197
JE::Code::Expression::eval('JE::Code::Expression=ARRAY(0xc5fa87c)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1377
JE::Code::Expression::_eval_term('JE::Code::Expression=ARRAY(0xc5fa87c)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1150
JE::Code::Expression::eval('JE::Code::Expression=ARRAY(0xc5fa78c)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 349
JE::Code::Statement::eval('JE::Code::Statement=ARRAY(0xc5e50e8)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 186
eval {...} called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 157
JE::Code::execute('JE::Code=HASH(0xcb4a5c0)', 'WWW::Scripter::Plugin::JavaScript::JE=REF(0xa7c76e8)', 'JE::Scope=ARRAY(0xcb4fc7c)', 2) called at /usr/lib/perl5/site_perl/5.8.8/JE/Object/Function.pm line 486
JE::Object::Function::apply('JE::Object::Function=REF(0xcb4aaac)', 'WWW::Scripter::Plugin::JavaScript::JE=REF(0xa7c76e8)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Object/Function.pm line 351
JE::Object::Function::call('JE::Object::Function=REF(0xcb4aaac)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1287
JE::Code::Expression::eval('JE::Code::Expression=ARRAY(0xc607808)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1377
JE::Code::Expression::_eval_term('JE::Code::Expression=ARRAY(0xc607808)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1182
JE::Code::Expression::eval('JE::Code::Expression=ARRAY(0xc5a0798)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1377
JE::Code::Expression::_eval_term('JE::Code::Expression=ARRAY(0xc5a0798)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 1150
JE::Code::Expression::eval('JE::Code::Expression=ARRAY(0xc5a0600)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 349
JE::Code::Statement::eval('JE::Code::Statement=ARRAY(0xc3abbc0)') called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 186
eval {...} called at /usr/lib/perl5/site_perl/5.8.8/JE/Code.pm line 157
谢谢