Express.js与Phantom.js

Bil*_*say 1 seo node.js express phantomjs

我正在使用Greg Franko伟大的Backbone-Require-Boilerplate而我正在考虑搜索引擎优化,所以我找到了Phantom.js

现在我正在尝试整合它并找到它. http://backbonetutorials.com/seo-for-single-page-apps/

这看起来像答案,但无法使这项工作.我安装了PhantomJs.

我的server.js是

// DEPENDENCIES
// ============
var express = require("express"),
    http = require("http"),
    port = (process.env.PORT || 8001),
    server = module.exports = express();

// SERVER CONFIGURATION
// ====================
server.configure(function() {

  server.use(express["static"](__dirname + "/../public"));

  server.use(express.errorHandler({

    dumpExceptions: true,

    showStack: true

  }));

  server.use(server.router); 

  server.get(/(.*)/, respond);

});

// SERVER
// ======

// Start Node.js Server
var app = http.createServer(server);
app.listen(port);
Run Code Online (Sandbox Code Playgroud)

那我怎么能插入Phantom.js呢?

awe*_*khh 6

如果您正在寻找与快递集成的节点,请查看以下内容:

https://github.com/Obvious/phantomjs

编辑:

这是一个工作的phantomjs节点模块:

https://github.com/amir20/phantomjs-node

var phantom = require('phantom');

phantom.create().then(function(ph) {
  ph.createPage().then(function(page) {
    page.open('https://stackoverflow.com/').then(function(status) {
      console.log(status);
      page.property('content').then(function(content) {
        console.log(content);
        page.close();
        ph.exit();
      });
    });
  });
});
Run Code Online (Sandbox Code Playgroud)