我有一個PhantomJS腳本時,我本地運行(蘋果機),但是當我在我的Linux服務器上運行它的工作原理,它返回以下錯誤:
ReferenceError: Can't find variable: $
https://fantasy.premierleague.com/a/statistics/value_form:5712 in global code
的代碼是:
var page = require('webpage').create();
var fs = require('fs');
var args = require('system').args;
page.settings.userAgent = 'SpecialAgent';
page.open('https://fantasy.premierleague.com/a/statistics/value_form', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function() {
var result ="";
// ...
return result;
});
}
phantom.exit();
});
爲什麼不只是請求這個網址:https://fantasy.premierleague.com/drf/bootstrap-static?我沒有看到使用phantomjs的好處,因爲它實際上會自動請求API並獲取數據。 – num8er
哇...我不相信實際存在,謝謝! –
您使用哪個** PhantomJS版本**?請註冊onConsoleMessage,onError,onResourceError,onResourceTimeout事件([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file-1_phantomerrors-js))。也許有錯誤。 –