【问题标题】:Fatal error when scraping dynamic page content with x-ray and x-ray-phantom使用 x-ray 和 x-ray-phantom 抓取动态页面内容时出现致命错误
【发布时间】:2015-12-20 12:44:26
【问题描述】:

当我在节点上运行 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"
  }
  ...
}

我的node版本是v5.3.0,npm版本是3.3.12,Phantomjs版本是1.9.8。我在 Mac El Capitan 10.11.1

【问题讨论】:

  • 我遇到了同样的问题,将 node.js 从 v5.3.0 降级到 v4.2.4,进行了 npm 重建,一切正常。

标签: node.js web-scraping x-ray


【解决方案1】:

检查这是否有效:

x = new Xray().driver(phantom({ dnodeOpts: { weak: false } }));

我使用phantom 而不是x-ray-phantom,我遇到了同样的问题。看来模块node-weak 已损坏(https://github.com/TooTallNate/node-weak/issues/65),绕过此模块为this link suggests 解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多