Get URL Contents in Node.js with Express

前端 未结 3 1542
暖寄归人
暖寄归人 2020-12-25 15:19

How would I go about downloading the contents of a URL in Node when using the Express framework? Basically, I need to complete the Facebook authentication flow, but I can\'t

3条回答
  •  滥情空心
    2020-12-25 15:49

    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

提交回复
热议问题