我已经设置了一个非常基本的测试页面,其中包含以下代码:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var a = 1;
});
</script>
</body></html>
然而,这无法在Windows 2008 Server下加载jQuery库,并在'var a = 1'赋值时抛出javascript错误。如果我将其更改为http协议,它似乎是在Windows 2008 Server上加载页面而没有错误。但是,相同的脚本在Windows 7上使用https模式时效果很好。
实际幻像脚本:
var system = require('system');
if (system.args.length < 3) {
console.log("Missing arguments.");
phantom.exit();
}
var server = require('webserver').create();
var port = parseInt(system.args[1]);
var urlPrefix = system.args[2];
var parse_qs = function(s) {
var queryString = {};
var a = document.createElement("a");
a.href = s;
a.search.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
return queryString;
};
var renderHtml = function(url, cb) {
var page = require('webpage').create();
page.settings.loadImages = false;
page.settings.localToRemoteUrlAccessEnabled = false;
page.onCallback = function() {
cb(page.content);
page.close();
};
page.onInitialized = function() {
page.evaluate(function() {
setTimeout(function() {
window.callPhantom();
}, 10000);
});
};
page.open(url, function(status) {
console.log('Status: ' + status);
});
page.onError = function(msg, trace) {
console.log(new Date());
console.log(msg);
trace.forEach(function(item) {
console.log(' ', item.file, ':', item.line);
});
}
};
server.listen(port, function (request, response) {
var url = 'https://www.sometestsite.com/test.html';
renderHtml(url, function(html) {
//console.log(html);
response.statusCode = 200;
response.write(html);
response.close();
});
});
console.log('Listening on ' + port + '...');
console.log('Press Ctrl+C to stop.');
以下是我在Win 2008 Server上遇到的错误,尝试传递--web-security = false:
C:\ PhantomJS&gt; phantomjs --disk-cache = no --web-security = false myscript.j s 7778 https://www.sometestsite.com/ 听7778 ...... 按Ctrl + C停止。 现状:成功 Wed Aug 13 2014 08:03:59 GMT-0700(太平洋夏令时) ReferenceError:找不到变量:$ https://www.sometestsite.com/test.html:8
上述代码在Windows 7上运行但在Windows 2008 Server上运行的任何想法
由于