簡體   English   中英

Node.js和幻影問題

[英]Node.js and phantom issue

我正在玩Node.js和可用的節點模型模塊。 但是我似乎停留在基本級別上,並且無法使這些基本代碼起作用:

var phantom = require('phantom');
phantom.create(function(ph) {
  return ph.createPage(function(page) {
    return page.open("http://www.google.com", function(status) {
      console.log("opened google? ", status);
      return page.evaluate((function() {
        return document.title;
      }), function(result) {
        console.log('Page title is ' + result);
        return ph.exit();
      });
    });
  });
});

我真的無法弄清楚為什么控制台消息沒有出現? 我想這恰好在一個幻影范圍內,但是我是否有可能將消息解析到節點上? 還是問題完全是其他東西?

從自述文件:

首先,確保已安裝PhantomJS。 該模塊希望phantomjs二進制文件位於PATH中的某個位置。 換句話說,鍵入:

$ phantomjs

如果可行,phantomjs-node也可以。 它僅在PhantomJS 1.3中經過測試,幾乎可以肯定不能在任何較舊的版本中使用。

如果不起作用(我期望什么),請安裝phantomjs: http ://phantomjs.org/download.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM