Hi again Anonymous Monk (and anyone else who may be able to help),

Having had a look at the links you've provided, I decided to give WWW::Mechanize::PhantomJS a try.

I installed the current version (0.06) on the commercial webhost that I use, using the cPanel webhosting control panel. The server is CentOS. I could not see any errors during the installation - it looked as if it installed OK. I then tried a couple of examples, including the first one at the top of the documentation page, and it fails. I then added warnings and strict, and here's the resulting code:

#!/usr/bin/perl -w use strict; use WWW::Mechanize::PhantomJS; my $mech = WWW::Mechanize::PhantomJS->new(); $mech->get('http://google.com'); $mech->eval_in_page('alert("Hello PhantomJS")'); my $png= $mech->content_as_png();
And here's the warning and error which result:
Can't exec "phantomjs": No such file or directory at /home/tel2/perl5/ +lib/perl5/WWW/Mechanize/PhantomJS.pm line 101. Couldn't launch [| phantomjs /home/tel2/perl5/lib/perl5/WWW/Mechanize/ +PhantomJS/ghostdriver/main.js --PhantomJS=8910 --logLevel=OFF]: No su +ch file or directory / 0 at /home/tel2/perl5/lib/perl5/WWW/Mechanize/ +PhantomJS.pm line 101.

Here is that section of code in PhantomJS.pm:

# Launch PhantomJs $options{ launch_exe } ||= 'phantomjs'; (my $ghostdir_default= __FILE__) =~ s!\.pm$!!; $ghostdir_default= File::Spec->catfile( $ghostdir_default, 'ghostd +river', 'main.js' ); $options{ launch_ghostdir } ||= $ghostdir_default; $options{ launch_arg } ||= []; push @{ $options{ launch_arg }}, "--PhantomJS=$options{ port }"; push @{ $options{ launch_arg }}, "--logLevel=\U$options{ log }"; my $cmd= "| $options{ launch_exe } $options{ launch_ghostdir } @{ +$options{ launch_arg } }"; #warn $cmd; $options{ pid } ||= open my $fh, $cmd or die "Couldn't launch [$cmd]: $! / $?";
The last line is line 101.

I've googled a bit for answers, but nothing yet. Any ideas what the problem is, or how to fix this?

Thanks again.
tel2


In reply to Re: Clicking a button with WWW::Mechanize by tel2
in thread Clicking a button with WWW::Mechanize by tel2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.