Node.js 为什么在使用梦魇.js或phantom.js清理网站时显示phantom std out错误
我正在尝试使用phantom.js编写一个网络蜘蛛。然而,我得到了很多错误信息,我不知道为什么。我的代码如下所示:Node.js 为什么在使用梦魇.js或phantom.js清理网站时显示phantom std out错误,node.js,web-crawler,phantomjs,nightmare,Node.js,Web Crawler,Phantomjs,Nightmare,我正在尝试使用phantom.js编写一个网络蜘蛛。然而,我得到了很多错误信息,我不知道为什么。我的代码如下所示: 使用噩梦.js: var Nightmare = require('nightmare'); new Nightmare() .goto('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q') .evaluate( function(){
- 使用噩梦.js:
var Nightmare = require('nightmare'); new Nightmare() .goto('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q') .evaluate( function(){ return document.getElementById('priceblock_ourprice').textContent; }, function( numAnchors ){ console.log(numAnchors); }) .run();
var page = require('webpage').create(); console.log('The default user agent is ' + page.settings.userAgent); page.open('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q', function(status) { if (status !== 'success') { console.log('Unable to access network'); } else { var ua = page.evaluate(function() { return document.getElementById('priceblock_ourprice').textContent; }); console.log(ua); } phantom.exit(); });
- 使用phantom.js:
var Nightmare = require('nightmare'); new Nightmare() .goto('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q') .evaluate( function(){ return document.getElementById('priceblock_ourprice').textContent; }, function( numAnchors ){ console.log(numAnchors); }) .run();
var page = require('webpage').create(); console.log('The default user agent is ' + page.settings.userAgent); page.open('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q', function(status) { if (status !== 'success') { console.log('Unable to access network'); } else { var ua = page.evaluate(function() { return document.getElementById('priceblock_ourprice').textContent; }); console.log(ua); } phantom.exit(); });
phantom stdout: ReferenceError: Can't find variable: ue.......
........
........
phantom stdout: TypeError: 'null' is not an object (evaluating 'old_error_handler.apply')
.......
$35.99
我可以在最后一行中得到结果,但是上面显示的错误太多了,原因是什么?这种情况会经常发生。当前的PhantomJS(1.9.7)基于与Chrome 13或Safari 5相当的旧QtWebkit fork。有问题的页面很可能在JavaScript中使用了PhantomJS不理解的东西。大多数情况下,这没什么可担心的,因为该站点仍将按预期运行。您是否找到过禁用它的方法?