问题描述
我的tor已连接到127.0.0.1:9051
,它说它不是http代理,那么我如何才能真正使用它以编程方式连接到网站(最好是node.js)?
(Trying to connect using http GET)
像有发送请求的特定方法吗?
预先感谢?
解决方法
您可以使用Axios进行请求并将代理设置为TOR SOCKS代理。 像下面一样
const axios = require('axios');
const SocksProxyAgent = require('socks-proxy-agent');
const proxyOptions = `socks5://$127.0.0.1:9050`;
const httpsAgent = new SocksProxyAgent(proxyOptions);
const baseUrl = 'https://example.com'
const client = axios.create({baseUrl,httpsAgent});
client.get('/something').then(res => res.data);