节点骑士与phantomjs-prebuilt失败

时间:2017-01-04 23:37:24

标签: node.js ssl phantomjs node-modules node-horseman

所以我整天都在撞墙,试图弄清楚问题是什么,但尚未找到解决方案。我已经发布了下面的所有npm模块,测试代码和输出。当我安装" phantomjs@1.9"使用npm测试代码可以正常工作,但是当我更新到最新的phantomjs-prebuilt模块时,下面的代码失败了。

我基本上是尝试使用phantomjs浏览Hulu并截取不同页面的截图。

我已经阅读了1.9和>之间的变化。 2.0似乎已经进行了一些SSL更改。当我" ps aux | grep phantom"我得到以下流程信息:

  

/ huntsman / node_modules / phantomjs-prebuilt / lib / phantom / bin / phantomjs --load-images = true --ssl-protocol = any --ignore-ssl-errors = true --web-security = false /用户/ pherlihy /工作/猎人/ node_modules /节点幻像简单/ bridge.js

据我所知,根据我的研究设置" web-security = false"," ssl-protocol = any"和" ignore-ssl-errors = true"应该解决任何问题,但这还有问题。

如果有任何想法请告诉我,谢谢。

供参考我正在使用:

  

" node-horseman":" ^ 3.2.0"

     

" phantomjs-prebuilt":" ^ 2.1.14"

我正在使用的测试代码:

var Horseman = require('node-horseman');

//Create the Horseman instance
var horseman = new Horseman({
  timeout: 10000,
  injectJquery: true,
  ignoreSSLErrors: true,
  webSecurity: false
})

//User agent
.userAgent().then(function(arg_ua)
{
  console.log(arg_ua);
  return this;
})

//Viewport
.viewport(1280, 720)

//Open
.open('http://hulu.com')

//Success
.then(function()
{
  console.log('success!');
})

.catch(function(arg_error)
{
  console.log(arg_error);
});

我正在使用的输出:

  

DEBUG =骑手,​​骑手:冗长

node index.js 
  horseman using PhantomJS from phantomjs-prebuilt module +0ms
  horseman .setup() creating phantom instance 1 +5ms
  horseman phantom created +1s
  horseman phantom version 2.1.1 +17ms
  horseman page created +12ms
  horseman phantomjs onLoadFinished triggered success NaN +8ms
  horseman injected jQuery +23ms
  horseman .userAgent() get +12ms
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
  horseman .viewport() set 1280 720 +0ms
  horseman .open() http://hulu.com +4ms
  horseman phantomjs onLoadFinished triggered fail 1 +3s
Error: Failed to GET url: http://hulu.com
    at checkStatus (/home/horseman/node_modules/node-horseman/lib/actions.js:78:16)
    at PassThroughHandlerContext.finallyHandler (/home/horseman/node_modules/bluebird/js/release/finally.js:56:23)
    at PassThroughHandlerContext.tryCatcher (/home/horseman/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/horseman/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/horseman/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/horseman/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/horseman/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/home/horseman/node_modules/bluebird/js/release/promise.js:636:18)
    at /home/horseman/node_modules/bluebird/js/release/nodeback.js:42:21
    at /home/horseman/node_modules/node-phantom-simple/node-phantom-simple.js:60:18
    at IncomingMessage.<anonymous> (/home/horseman/node_modules/node-phantom-simple/node-phantom-simple.js:645:9)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  horseman phantomjs onLoadFinished triggered success 2 +4s
  horseman jQuery not injected - already exists on page +5ms

0 个答案:

没有答案