Using phantom on Node webkit

大兔子大兔子 提交于 2019-12-24 12:37:28

问题


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
  • Chromium 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.


回答1:


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).

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

Basically, you would

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

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


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


来源:https://stackoverflow.com/questions/33602935/using-phantom-on-node-webkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!