Problem with http GET request on node js

后端 未结 2 751
悲&欢浪女
悲&欢浪女 2021-02-15 13:24

Im writing an http client to read from facebook using node.js and using the following code:

var http = require(\'http\');

var options = {
  host: \'www.fb.com\'         


        
相关标签:
2条回答
  • 2021-02-15 13:36
    var request_options = 
    {
        host: 'www.fb.com',
        headers: {'user-agent': 'Mozilla/5.0'},
        path: '/'
    };
    

    Setting the request option this way should work.

    0 讨论(0)
  • 2021-02-15 13:58

    This dosent seem to be a bug of node.js I made a request to fb.com in curl and I got the same redirect.

    It probably makes that decision based on the user agent... maybe you can use the user agent of a browser :D

    0 讨论(0)
提交回复
热议问题