简体   繁体   中英

NodeJS X-Ray Hide IP Address

使用NodeJS / X-Ray向外部站点发出请求时,是否可以更改IP地址和用户代理?

Yes you can.

But instead of passing the url(s) you want to scrape to x-ray, rather use the request module to get the response, and pass that to x-ray. This will allow you to pass options into the request module, which will allow you to change your User Agent as well as use a proxy (which is the best way to 'change' your IP).

var options = {
    headers: {'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)'},
    proxy: 'http://us-ny.proxymesh.com:31280',
    strictSSL: false
};

request(url, options, function (err, response) {

    xray(response.body, {
        //x-ray selectors            
    })
    (function (err, obj) {
    //parse results
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM