使用X射线和X射线幻像来抓取dynamic页面内容时发生致命错误

我在节点上运行app.js时,在命令行中出现此错误:

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope Abort trap: 6 

这就是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')); }) 

我的package.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 = new Xray().driver(phantom({ dnodeOpts: { weak: false } }));

我使用phantom而不是x-ray-phantom ,我遇到了同样的问题。 看起来,模块node-weakhttps://github.com/TooTallNate/node-weak/issues/65 ),并绕过这个模块,因为这个链接build议已经解决了我的情况。