url=about:blank willNavigate=true, isMainFrame=false 的 casperjs 解决方法
casperjs workaround for url=about:blank willNavigate=true, isMainFrame=false
我卡在一个页面上 returns 4 行像这样然后挂断了:
[debug] [phantom] opening url: https://xxx, HTTP GET
[debug] [phantom] Navigation requested: url=https://xxx, type=Other, willNavigate=true, isMainFrame=true
[info] [phantom] Step anonymous 3/6: done in 170ms.
[debug] [phantom] url changed to "https://xxx"
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
我以这种方式启动命令,因为我读到了几个与 ssl 相关的错误,并且它适用于整个网站 xxx:
casperjs --ignore-ssl-errors=true --ssl-protocol=any script.js
我的代码没有嵌套,因为它是我自己生成的 class。然而这很简单:
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7');
casper.start().then(function() {
this.open('https://xxx', {
headers: {
'Accept': 'text/html'
}
});
});
casper.then(function () {
this.viewport(1920, 1080);
});
casper.wait(
3000,
function () {
this.echo('timeout occured');
}
);
casper.then(function() {
this.capture('capture.png', {
top: 0,
left: 0,
width: 1920,
height: 1080
});
});
casper.run();
我需要专家的提示,不幸的是我不是。提前谢谢你
已在 phantomjs 1.9.8 中修复,不要相信 apt-get 常规源 (1.9.0-1) 和指南。如果将它与 casperjs 结合使用,请不要使用 2.00,因为它不受支持。
UBUNTU 的说明,对于 CENTOS,将 apt-get 替换为 yum。
sudo apt-get update
apt-get install python
apt-get install ttf-mscorefonts-installer
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
我卡在一个页面上 returns 4 行像这样然后挂断了:
[debug] [phantom] opening url: https://xxx, HTTP GET
[debug] [phantom] Navigation requested: url=https://xxx, type=Other, willNavigate=true, isMainFrame=true
[info] [phantom] Step anonymous 3/6: done in 170ms.
[debug] [phantom] url changed to "https://xxx"
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
我以这种方式启动命令,因为我读到了几个与 ssl 相关的错误,并且它适用于整个网站 xxx:
casperjs --ignore-ssl-errors=true --ssl-protocol=any script.js
我的代码没有嵌套,因为它是我自己生成的 class。然而这很简单:
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7');
casper.start().then(function() {
this.open('https://xxx', {
headers: {
'Accept': 'text/html'
}
});
});
casper.then(function () {
this.viewport(1920, 1080);
});
casper.wait(
3000,
function () {
this.echo('timeout occured');
}
);
casper.then(function() {
this.capture('capture.png', {
top: 0,
left: 0,
width: 1920,
height: 1080
});
});
casper.run();
我需要专家的提示,不幸的是我不是。提前谢谢你
已在 phantomjs 1.9.8 中修复,不要相信 apt-get 常规源 (1.9.0-1) 和指南。如果将它与 casperjs 结合使用,请不要使用 2.00,因为它不受支持。
UBUNTU 的说明,对于 CENTOS,将 apt-get 替换为 yum。
sudo apt-get update
apt-get install python
apt-get install ttf-mscorefonts-installer
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin