【发布时间】:2015-01-08 06:32:41
【问题描述】:
我有一个 JS 文件添加标题如下。
var webPage = require('webpage');
var system = require('system');
var page = webPage.create();
page.customHeaders = {"pragma": "akamai-x-feo-trace"};
page.settings.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"
if (system.args.length === 1) {
console.log('Try to pass some args when invoking this script!');
} else {
page.open(system.args[1], function (status) {
var content = page.content;
console.log(content);
phantom.exit();
});
}
我现在正在执行以下幻象命令
phantomjs RequestURL.js http:////www.ubank.com.au > body.html
打开body.html 后,我得到一个空的 HTML 文件,如下所示。
<html><head></head><body></body></html>
为什么这里没有生成 HTML 源代码。
【问题讨论】:
-
尝试使用 service_args=['--ignore-ssl-errors=true']。见这里stackoverflow.com/questions/23581291/…
-
我现在尝试了
phantomjs RequestURL.js service_args=['--ignore-ssl-errors=true'] http:////www.ubank.com.au > body.html仍然是空的html -
http:////www.ubank.com.au绝对不是有效的 URL。试试http://www.ubank.com.au
标签: javascript jquery html phantomjs