Phantomjs Mechanization Setup

I have a problem. I want to use WWW :: Mechanize :: PhantomJS. I set it as it should. 1. Installed Strawberry and WWW :: Mechanization :: PhantomJS Module 2. Download PhantomJS zip, extract it and set the path for the phantomjs executable. 3. Created a sample script as follows:

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();

but when I execute this script, I get the following error:

Selenium server did not return proper status at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 395.

What am I missing. I assume that this WWW :: Mechanize :: PhantomJS starts phantomjs from the path specified in the environment.

Edit: I uninstall WWW :: Mechanize :: PhantomJS and tried to install again, but received the following output:

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.

Then, as suggested, I changed C: \ Strawberry \ perl \ vendor \ lib \ LWP \ Protocol \ http.pm as follows

   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';
    }

and again the cpan command is issued WWW :: Mechanization :: PhantomJS but the same result again.

+4

Source: https://habr.com/ru/post/1621413/


All Articles