我遇到了一个问题。 我想使用WWW :: Mechanize :: PhantomJS。我把它设置如下。 1.安装草莓和WWW :: Mechanize :: PhantomJS模块 2.Downloaded PhantomJS zip,解压缩并设置phantomjs可执行文件的路径。 3.创建了一个示例脚本如下:
BEGIN{
$ENV{HTTPS_PROXY} = 'http://myproxyserver:port';
$ENV{HTTP_PROXY} = 'http://myproxyserver:port';
}
use WWW::Mechanize::PhantomJS;
use Data::Dumper;
my $mech = WWW::Mechanize::PhantomJS->new();
$mech->get('http://google.com');
print Dumper $mech->content();
但是当我执行此脚本时,我收到以下错误:
Selenium server did not return proper status at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 395.
我失踪了什么。 我假设这个WWW :: Mechanize :: PhantomJS从环境中指定的路径启动phantomjs。
编辑: 我卸载了WWW :: Mechanize :: PhantomJS并尝试重新安装,但得到了以下输出:
t/00-load.t ................... ok
t/49-mech-get-file.t .......... # Testing with C:\bin\phantomjs\phantomjs.exe
Selenium server did not return proper status at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 395.
# Looks like your test exited with 9 before it could output anything.
t/49-mech-get-file.t .......... Dubious, test returned 9 (wstat 2304, 0x900)
Failed 12/12 subtests
t/49-mech-nav.t ............... # Testing with C:\bin\phantomjs\phantomjs.exe
Selenium server did not return proper status at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 395.
然后按照建议我修改了C:\ Strawberry \ perl \ vendor \ lib \ LWP \ Protocol \ http.pm,如下所示
sub _new_socket
{
my($self, $host, $port, $timeout) = @_;
# IPv6 literal IP address should be [bracketed] to remove
# ambiguity between ip address and port number.
if ( ($host =~ /:/) && ($host !~ /^\[/) ) {
#$host = "[$host]";
$host = '127.0.0.1';
}
再次发出命令 cpan WWW :: Mechanize :: PhantomJS 但同样的输出。