0

I'm trying to take screen shots of the web pages without using Mechanize::Firefox.

I tried with the Wight module, will communicate with PhantomJS.

I'm able to take screen shots of http: sites but I can't take the screen shots for https: sites.

I have searched it and found a solution here PhantomJS failing to open HTTPS site which is to add a command-line option

phantomjs --ssl-protocol=any  test.js

But I'm running PhantomJS inside the Wight module and I don't know how to apply the --ssl-protocol inside the script

This is what I have tried

use strict;

use Wight;

my %arg = ( phantomjs => 'phantomjs', protocal => '--ssl-protocol=any');
my $wight = Wight->new(%arg);

$wight->visit('https:...');

$wight->evaluate('document.title');
$wight->render('anv.png');
Borodin
  • 126,100
  • 9
  • 70
  • 144
mkHun
  • 5,891
  • 8
  • 38
  • 85

1 Answers1

1

The correct way to do this is to call phantomjs_args on the new object, like this

my $wight = Wight->new;
$wight->phantomjs_args( '--ssl-protocol=any' );
Borodin
  • 126,100
  • 9
  • 70
  • 144
  • Can you explain why should not pass it as a argument? – mkHun Jan 22 '18 at 12:57
  • 1
    Because the value of the hash key is hidden in the code, and you shouldn't assume any particular implementation of the interface. The documentation is particularly poor, and the `phantomjs_args` method isn't documented either, but it's clear from the code that it's supposed to be an accessor method. Note also that the `phantomjs` option doesn't need to be set, as `'phantomjs'` is the default. – Borodin Jan 22 '18 at 13:09