我知道有一些网页PhantomJS/CasperJS无法打开,我想知道这个是否是其中之一:https://maizepages.umich.edu .CasperJS给出错误:PhantomJS无法打开页面状态=失败.
我尝试忽略-ssl-errors并更改我的用户代理但我不确定如何确定使用哪些.
我现在正在做的就是基本的casper设置在casper.start(url, function () { ... })哪里url=https://maizepages.umich.edu;
我试图通过嵌入所有图像(以及我通过此点后的其他外部资源)将网页转换为单个文件.以下是我运行PhantomJs的方法:
./phantomjs --web-security=false ./embed_images.js http://localhost/index.html > output.txt
Run Code Online (Sandbox Code Playgroud)
这是embed_images.js:
var page = require('webpage').create(),
system = require('system'),
address;
if (system.args.length === 1) {
console.log('Usage: embed_images.js <some URL>');
phantom.exit(1);
}
else {
page.onConsoleMessage = function(msg) {
console.log(msg);
};
address = system.args[1];
page.open(address, function(status) {
page.evaluate(function() {
function embedImg(org) {
var img = new Image();
img.src = org.src;
img.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(this, 0, 0);
var dataURL = …Run Code Online (Sandbox Code Playgroud)