我正在尝试使用phantomJS的简单代码,但没有运气。无法刮取PhantomJS的特定网页
var page = new WebPage();
var system = require('system');
var site=system.args[1];
var page = require('webpage').create();
page.onError = function (msg, trace)
{
console.log(msg);
trace.forEach(function(item) {
console.log(' ', item.file, ':', item.line);
})
}
page.open("https://www.mightydeals.co.uk/Products/all/National/Grey-
Small/132212", function(){
var p=page.evaluate(function(){
return [].map.call(document.querySelectorAll('#productInformation'),
function(link) {
return link.innerText;
});
});
console.log(p);
});
phantom.exit();
});
页以上的功能,也是在这里我代表:只有 Link to page
我得到的错误和无效的输出。
我需要获取产品说明,但它没有给出任何描述,只是错误。
我可以看到页面具有通过控制台,上面写着
未捕获的SyntaxError错误本身:意外令牌<
是造成问题或其他任何东西,请建议/咨询页面错误。
请用像jslint这样的工具检查你的脚本,看起来有语法错误。 – Vaviloff