plo*_*uzz 9 automation phantomjs casperjs slimerjs
这是我第一次使用无头浏览器打开网站:phantomjs,slimerjs或casperjs.我只想打开网站.我只是创建非常基本的脚本来打开网站并截取屏幕截图.但其中3个(三个)给我空白图片.
我尝试使用:
--debug=true
--ssl-protocol=TLSv1.2 (i try each of available protocol)
--ignore-ssl-errors=true
Run Code Online (Sandbox Code Playgroud)
我的脚本在这里:
Slimerjs
var page = require("webpage").create();
page.open("https://domain/")
.then(function(status){
if (status == "success") {
page.viewportSize = { width:1024, height:768 };
page.render('screenshot.png');
}
else {
console.log("Sorry, the page is not loaded");
}
page.close();
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)
phantomjs
var page = require('webpage').create();
page.open('https://domain/', function() {
page.render('screenshot.png');
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)
casperjs
var casper = require('casper').create({
viewportSize: {width: 950, height: 950}
});
casper.start('https://domain/', function() {
this.capture('screenshot.png');
});
casper.run();
Run Code Online (Sandbox Code Playgroud)
我甚至尝试使用屏幕捕获服务来了解它们是否可以打开.但是他们所有人都没有给我任何东西.
我有什么想念吗?
问题不在于PhantomJS本身.您正在检查的网站受到a的保护F5 network protection
https://devcentral.f5.com/articles/these-are-not-the-scrapes-youre-looking-for-session-anomalies
所以它不是页面不加载.保护机制根据已实施的检查检测到PhantomJS是机器人
最简单的修复方法是使用Chrome而不是PhantomJS.否则,这意味着相当多的调查时间
过去有些类似的未答复/回答的问题
Selenium和PhantomJS:网页认为Javascript已被禁用
PhantomJS没有在AWS EC2 CentOS 6上运行真正的内容
file_get_contents同时绕过javascript检测
Python POST请求不返回HTML,请求启用JavaScript
我将使用我找到的更多详细信息更新此帖子.但我的经验表明,继续使用有效的方法,而不是浪费时间在PhantomJS下不起作用的网站上
更新1
我曾尝试将浏览器cookie导入PhantomJS,但它仍无效.这意味着有一些硬性检查