如何在node.js的帮助下使用一个站点在localhost上工作?

我正在学习node.js,我正在尝试使用Google网页在本地主机上工作,其中的菜单项将被删除,但其searchfunction应该在本地主机上工作,因为它在网站上工作。 这我试图在本地主机上使用谷歌,但在本地主机上显示“不能得到”,这是一种错误,或者我做错了,请指导我,我如何能实现我想工作。 我在XP上使用node.js ver5.9.1。

提前致谢。

search.js

var express = require('express'), app = express(); var bodyParser = require('body-parser'); compression = require('compression'); var NLTunnel = require('node-local-tunnel'); var options = { remoteHost : 'http://www.google.com/', localBase : 'http://localhost:3000' }; NLTunnel.client(options); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended:true})); app.use(compression()); app.use(express.static('assets/')); app.listen(3000); 

  var express = require('express'), app = express(), bodyParser = require('body-parser'), compression = require('compression'), http = require('http'), server = http.createServer(app); app.use(bodyParser()); app.use('/', express.static('public')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended:true})); app.use(compression()); server.listen(3000); 

尝试这个。 这是在我的机器上工作。

我曾尝试使用请求cheerio,但我只得到HTML页面,没有任何CSSJS页(如果有)和searchfunction也无法正常工作。 这是正确的工作,以及如何使本地主机上的searchfunction正常工作。

 var httpobj = require('http'); var request = require('request'); var cheerio = require('cheerio'); var all_html; var url = 'https://www.google.co.in/?gfe_rd=cr&ei=dVHeVuLuG-uK8QeCk6vICw' request(url, function (error, response, html) { var $page = cheerio.load(html); all_html = $page("html"); }); httpobj.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(all_html + ' '); res.end(''); }).listen(8124, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8124/');