CasperJS/PhantomJS无法打开Facebook



我看过这样的例子,展示了如何使用casperJS登录facebook:如何使用CasperJS登录网站?

但是我无法让这段代码为我工作。 我对登录部分不感兴趣,我只想将任何 facebook 页面加载到 casperjs 或 phantomjs 中,但加载时不断失败。

这对其他人有用吗? 还是Facebook检测到浏览器并且不再允许访问?

这是我无法做的简化版本:

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

我正在Windows 7上运行它

看起来这是 casperjs 窗口批处理文件的已知错误:

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

最新更新