CasperJS/PhantomJS无法打开Facebook [英] CasperJS/PhantomJS unable to open Facebook

查看:81
本文介绍了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 Windows批处理文件的已知错误:

https://github.com/n1k0/casperjs/commit/0d659f140f1e2120bed967d8301657b5fe79f19 /p>

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

解决方案

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

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

这篇关于CasperJS/PhantomJS无法打开Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆