2014-02-14 35 views
1

我尝试打开使用facebook插件的页面,但casperJS不加载它。如何使用facebook插件加载页面?无法用facebook插件打开页面casperJS

var casper = require("casper").create({ 
      verbose: true, 
      logLevel: 'debug', 
      pageSettings: { 
      userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0' 
      } 
     }), 
     utils = require('utils'); 

    casper.start(); 

    casper.thenOpen('http://bookmate.com', function(response) { 
     this.echo(this.getTitle()); 
    }); 

    casper.run(function() { 
     console.log('End'); 
     casper.exit(); 
    }); 

结果:

[info] [phantom] Starting... 
[info] [phantom] Running suite: 2 steps 
[debug] [phantom] opening url: http://bookmate.com/, HTTP GET 
[debug] [phantom] Navigation requested: url=http://bookmate.com/, type=Other, willNavigate=true, isMainFrame=true 
[debug] [phantom] url changed to "http://bookmate.com/" 
[debug] [phantom] Navigation requested: url=https://www.facebook.com/plugins/facepile.php?app_id=124791507543584&href=http://facebook.com/bookmate&action=like&width&height=70&max_rows=1&colorscheme=light&size=medium&show_count=true, type=Other, willNavigate=true, isMainFrame=false 

我尝试打开在这里我们使用Facebook插件的页面,但casperJS不会加载它。如何使用facebook插件加载页面?

+0

我试图中止请求,但它似乎并不工作http://docs.casperjs.org/en/latest/events-filters.html#page-resource-requested –

回答

1

这个问题实际上并不是CasperJS,而是PhantomJS。当您针对SlimerJS引擎运行时,相同的脚本可以正常工作。

我试图用下面的脚本在phantomjs上打开页面,看它是否挂起。

var page = require('webpage').create(); 
var url = 'http://bookmate.com/'; 
page.open(url, function (status) { 
    //Page is loaded! 
    phantom.exit(); 
});