C#使用Privoxy / TOR

我找到了许多使用Privoxy / TOR代理的例子。 例如: 如何使用Tor来创建C#HttpWebRequest

首先我安装了Vidalia Bundle,而且还安装了Privoxy。

Vidalia Bundle使用地址127.0.0.1:9115
Privoxy使用地址127.0.0.1:8118

我在服务器http://whatismyipaddress.com/上尝试代码创建请求。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://whatismyipaddress.com/"); request.Proxy = new WebProxy("127.0.0.1:8118"); using (var response = request.GetResponse()) { using (var reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"))) { webBrowser1.DocumentText = reader.ReadToEnd(); } } 

但是这台服务器仍然看到我的IP地址。 我做错了什么? 任何提前,谢谢。

用leppie建议编辑:我使用这个构造函数:

  request.Proxy = new WebProxy("127.0.0.1",8118); 

但服务器仍然看到我的IP地址。 🙁

应用程序在端口8118上使用Privoxy。我需要在9115上使用 – 这是TOR端口。

我怀疑url是错的。

您应该使用WebProxy(string Host, int Port)构造函数。

这适用于远程代理:

 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://whatismyipaddress.com/"); request.Proxy = new WebProxy("110.139.166.78:8080"); using (var req = request.GetResponse()) { using (StreamReader reader = new StreamReader(req.GetResponseStream())) { Console.WriteLine(reader.ReadToEnd()); } } Console.ReadLine();