使用Express获取Node.js中的URL内容

如何在使用Express框架时下载Node中URL的内容? 基本上,我需要完成Facebook身份validationstream程,但是如果没有获取他们的OAuth令牌URL,我不能这样做。

通常情况下,在PHP中,我会使用Curl,但Node是什么?

var options = { host: 'www.google.com', port: 80, path: '/index.html' }; http.get(options, function(res) { console.log("Got response: " + res.statusCode); }).on('error', function(e) { console.log("Got error: " + e.message); }); 

http://nodejs.org/docs/v0.4.11/api/http.html#http.get

您将面临的问题是:某些网页使用JavaScript加载其内容。 因此,你需要一个软件包,比如After-Load模拟浏览器的行为,然后给你这个URL的HTML内容。

 var afterLoad = require('after-load'); afterLoad('https://google.com', function(html){ console.log(html); });