简体   繁体   English

Node.js和幻影问题

[英]Node.js and phantom issue

I'm playing around with Node.js and the node phantom module that is available. 我正在玩Node.js和可用的节点模型模块。 But I seem to be stuck at a basic level, and can't get this basic piece of code to work: 但是我似乎停留在基本级别上,并且无法使这些基本代码起作用:

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();
      });
    });
  });
});

I can't really figure out why the console messages don't appear? 我真的无法弄清楚为什么控制台消息没有出现? This happen to be in some phantom scope, I guess, but would it be possible for me to have the messages be parsed on to node? 我想这恰好在一个幻影范围内,但是我是否有可能将消息解析到节点上? Or is the problem something completely else? 还是问题完全是其他东西?

From the readme: 从自述文件:

First, make sure PhantomJS is installed. 首先,确保已安装PhantomJS。 This module expects the phantomjs binary to be in PATH somewhere. 该模块希望phantomjs二进制文件位于PATH中的某个位置。 In other words, type this: 换句话说,键入:

$ phantomjs

If that works, so will phantomjs-node. 如果可行,phantomjs-node也可以。 It's only been tested with PhantomJS 1.3, and almost certainly doesn't work with anything older. 它仅在PhantomJS 1.3中经过测试,几乎可以肯定不能在任何较旧的版本中使用。

if that doesnt work (what i expect) install phantomjs: http://phantomjs.org/download.html 如果不起作用(我期望什么),请安装phantomjs: http ://phantomjs.org/download.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM