2013-04-26 23 views
0

好吧,我是一個新手在這整個node.js,express.js事情如此裸露與我如果這是如此微不足道。我正在使用Greg Franko的Backbone-Require-Boilerplate,我一直在考慮搜索引擎優化,所以我找到了Phantom.jsExpress.js與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); 

因此,如何我會永遠堵塞Phantom.js在這?

非常感謝!

+0

phantom.js不是Node模塊,您必須單獨安裝phantom.js,然後從命令行運行它的腳本,例如:phantomjs hello.js我認爲您必須先使用phantom.js,然後實現您的SEO內容。查看:https://github.com/ariya/phantomjs/wiki/Quick-Start – marisks 2013-04-26 07:37:01

+0

Yeap,我安裝了phantomjs,那很好。我試圖在我上面給出的鏈接中完成所做的事情,但無法實現它的工作。 – Bilsay 2013-04-26 10:26:27

回答

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