使用 NodeJS/X-Ray 向外部站点发出请求时,是否可以更改您的 IP 地址和用户代理?
问问题
3042 次
1 回答
1
是的你可以。
但是,不要将要抓取的 url 传递给 x 射线,而是使用request
模块来获取响应,并将其传递给 x 射线。这将允许您options
进入request
模块,这将允许您更改您的用户代理以及使用代理(这是“更改”您的 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
}
});
于 2016-03-24T17:53:14.727 回答