我尝试访问网页并使用casperjs进行捕获,但在.png中没有显示任何内容,也没有生成最终的html DOM。(页面在Chrome浏览器中完美运行)
代码:
var casper = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casper.start("http://m.weibo.cn/status/Er9b7wxsD", function() {
this.wait(5000, function() {
this.scrollTo(0, 0);
this.echo(this.getHTML('html', true));
this.capture('all.png');
});
});
casper.run();
我正在使用CasperJS版本1.1.2和phantomjs版本2.1.1
非常感谢任何想法并提前致谢!
答案 0 :(得分:3)
将其添加到脚本的末尾:
casper.on("page.initialized", function(page) {
page.evaluate(function() {
delete window.callPhantom;
delete window._phantom;
});
});
基本上该网站正在检查您是否使用PhantomJS。
由于CasperJS在它上面运行(默认情况下),你什么也看不见