CasperJS/PhantomJS unable to open Facebook

2019-07-16 03:57发布

问题:

I've seen examples such as this one showing how to login to facebook with casperJS: How to login into a website with CasperJS?

but am unable to get this code to work for me. I'm not interested in the login portion, I just want to load any facebook page into casperjs or phantomjs but keep getting a fail on load.

Is this working for anyone else? or has facebook detected the browser and not allowing access anymore?

Here is a simplified version of what I am unable to do:

var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug',
    pageSettings:{
        userAgent :'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'    ,
        loadImages:  false,         // The WebPage instance used by Casper will
        loadPlugins: false         // use these settings
    }
});
casper.start()
casper.thenOpen('https://www.facebook.com/pfchangs', function() {

    this.echo(this.getHTML());
    //this just prints out empty page: <html><head></head><body></body></html>

});

casper.run();

I'm running this on Windows 7

回答1:

Looks like this is known bug with casperjs windows batch file:

https://github.com/n1k0/casperjs/commit/0d659f140f1e2120bed967d8301657b5fe79f19c