use*_*837 12 javascript tor node.js http-request
有没有办法使用与Node.js中的IP不同的IP发送HTTP请求?
我想从之前选择的IP发送请求,而不是从服务器的IP或我的计算机的IP发送请求.
我知道Tor Project会进行这种操作,但是我找不到Tor用来做这些东西的库.
是否有任何API或Node.js模块用于处理Node.js中的这种私人浏览?
Mik*_*ser 19
在节点http模块中,有一个localAddress选项用于绑定到特定的网络接口.
var http = require('http');
var options = {
hostname: 'www.example.com',
localAddress: '202.1.1.1'
};
var req = http.request(options, function(res) {
res.on('data', function (chunk) {
console.log(chunk.toString());
});
});
Run Code Online (Sandbox Code Playgroud)
在Github上查看Mikeal的请求.
Tor使用SOCKS5,这两个模块可以帮助:socks5-http-client和socks5-https-client
require('socks5-http-client').request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
Run Code Online (Sandbox Code Playgroud)
另一种选择是使用免费的Web代理,例如Hide My Ass Web代理.它们还提供了可以使用的ip:port代理列表.http,https甚至是SOCKS4/5.使用上述模块或只是将Web浏览器配置为使用其中一个.
您甚至可以设置自己的私有http代理节点应用程序并在Heroku上部署.我在Google上发现了大量易于理解的示例.
| 归档时间: |
|
| 查看次数: |
11309 次 |
| 最近记录: |