在Node Webkit上使用幻影 [英] Using phantom on Node webkit

查看:86
本文介绍了在Node Webkit上使用幻影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Phantom 来抓取Node webkit中的动态内容. 我也将phantomjs添加到env变量中. 当我运行该应用程序时,出现版本不匹配错误: 未捕获的错误:模块版本不匹配.预期为43,得到46." 通过运行nw:version我得到以下版本:

I am trying to scrape dynamic content in Node webkit by using Phantom . I have added phantomjs to env variable also. When i run the application i get a version mismatch error: "Uncaught Error: Module version mismatch. Expected 43, got 46." By running nw:version i get the following versions:

  • nw.js v0.12.3
  • io.js v1.2.0
  • 铬41.0.2272.76

我应该如何解决该错误? 如果您能够使用其他软件包实现类似的功能,请告诉我.

How should i get around this error? If you were able to implement similar functionality using some other package, let me know.

推荐答案

本机模块(幻像是其中之一,根据我的经验,必须重建 lwip )才能在nw.js中使用;您使用npm安装的软件不兼容.还建议安装与nw.js(即io.js 1.2.0)使用的版本相匹配的node.js.

Native modules (phantom is one of them, my experience was with lwip) must be rebuilt to work inside nw.js; the ones you install with npm are not compatible. It is also recommended to install node.js version matching that which is used by nw.js (i.e. io.js 1.2.0).

有关如何重建的说明: https ://github.com/nwjs/nw.js/wiki/build-native-modules-with-nw-gyp

The instruction on how to rebuild: https://github.com/nwjs/nw.js/wiki/build-native-modules-with-nw-gyp

基本上,您会

$ npm install -g nw-gyp
$ cd node_modules/phantom
$ nw-gyp configure --target=0.12.3
$ nw-gyp build

请注意configure中的"0.12.3"版本,因为这是您的nw:version显示的内容. 另外,请注意不同的先决条件,具体取决于您使用的操作系统: https://github.com/nwjs/nw -gyp

Note "0.12.3" version in configure because that's what your nw:version shows. Also, note different pre-requisites depending on which OS you use: https://github.com/nwjs/nw-gyp

要在nw.js中进行网络窃听,我成功使用了以下堆栈(在Windows 7上):

To do web-scarping in nw.js I successfully use the following stack (on Windows 7):

  • nw.js 0.12.3
  • phantomjs module with phantomjs 1.9.8 or 2.0.1b
  • node-phantom-simple module

这篇关于在Node Webkit上使用幻影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆