Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

javascript - Run phantomjs with --ignore-ssl-errors=true from casperjs

I have a problem with https page. Page is completly ok, it exist but phantomjs tell me something else: 'loading resource failed with status fail'. I read about it for a while and for now i know it's phantomjs bug and the solution to this problem is:

--ignore-ssl-errors=true

So I know solution, but don't how to use it. How can I pass this to phantomjs from casper? Where should I do that ?

EDIT:

Entire code:

var casper = require('casper').create({
        verbose: true,
        logLevel: 'warning',
        pageSettings: { javascriptEnabled:  true },
        viewportSize: {width: 1024, height: 768}
    });

    var url = 'http://us3.php.net/manual/en/function.explode.php',
        xp = require('casper').selectXPath;

    // ### AKCJE PODSTAWOWE ###
        casper.start(url);

            casper.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0');

            casper.then(function(){this.captureSelector('logi/img1.png', 'body');});

            casper.then(function(){ this.sendKeys(xp('/html/body/nav/div/div/div/form/span/input[2]'),'test18');});

            casper.then(function(){this.captureSelector('logi/img2.png', 'body');})

            casper.thenClick(xp('/html/body/div[3]/div/section/div/div[2]/a[1]'));

            casper.wait(2000);
            casper.then(function(){this.captureSelector('logi/img3.png', 'body');})

            casper.run(function(){ this.exit(); }); 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As per https://casperjs.readthedocs.org/en/latest/cli.html#casperjs-native-options

Last but not least, you can still use all PhantomJS standard CLI options as you would do with any other phantomjs script:

$ casperjs --web-security=no --cookies-file=/tmp/mycookies.txt myscript.js

So, I guess, it would be

casperjs --ignore-ssl-errors=true yourjsapp.js 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...