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

使用Express框架时,如何在Node中下载URL的内容?基本上,我需要完成Facebook身份验证流程,但是如果没有获取其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

以上是 使用Express获取Node.js中的URL内容 的全部内容, 来源链接: utcz.com/qa/398839.html

回到顶部