小编典典

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

node.js

使用Express框架时,如何在Node中下载URL的内容?基本上,我需要完成Facebook身份验证流程,但是如果没有获取其OAuth令牌URL,就无法做到这一点。

通常,在PHP中,我会使用Curl,但是Node等效项是什么?


阅读 362

收藏
2020-07-07

共1个答案

小编典典

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

2020-07-07