Node.js 使用x-ray和x-ray-phantom刮取动态页面内容时出现致命错误
在节点上运行app.js时,我在命令行中遇到此错误:Node.js 使用x-ray和x-ray-phantom刮取动态页面内容时出现致命错误,node.js,web-scraping,x-ray,Node.js,Web Scraping,X Ray,在节点上运行app.js时,我在命令行中遇到此错误: FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope Abort trap: 6 这就是am app.js的外观: var phantom = require('x-ray-phantom'); var Xray = require('x-ray'); var fs = require('fs'); x = new
FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
Abort trap: 6
这就是am app.js的外观:
var phantom = require('x-ray-phantom');
var Xray = require('x-ray');
var fs = require('fs');
x = new Xray().driver(phantom());;
x('http://www.bbc.co.uk/news', '.most-popular__list panel-read li', [{
content: ''
}])(function (err, results) {
fs.writeFile('results.json', JSON.stringify(results, null, '\t'));
})
mypackage.json
{
...
"dependencies": {
"phantomjs": "^1.9.19",
"x-ray": "^2.0.2",
"x-ray-phantom": "^1.0.1"
}
...
}
我的节点版本是v5.3.0,Npm版本是3.3.12,Phantomjs版本是1.9.8。我使用的是Mac El Capitan 10.11.1检查此功能是否有效:
x=新的x射线()驱动程序(幻影({
D选择:{
弱:错
}
}));代码>
我使用了phantom
而不是x-ray-phantom
,我遇到了同样的问题。似乎模块节点弱
已损坏(),并绕过此模块解决了我的问题。我遇到了相同的问题,将node.js从v5.3.0降级到v4.2.4,进行了npm重建,一切正常。