如何以编程方式使用Tor

问题描述

我的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);

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...