Answer the question
In order to leave comments, you need to log in
How to work with tor in C#?
Good afternoon! The problem is this: you need to send a request to the site w-th tor. This is achieved through such a simple design
HttpWebRequest reqPOST = HttpWebRequest.CreateHttp(@"...");
reqPOST.Method = "POST"; // Устанавливаем метод передачи данных в POST
reqPOST.Timeout = 120000; // Устанавливаем таймаут соединения
reqPOST.Headers.Set(HttpRequestHeader.Cookie, this.cookies);
reqPOST.UserAgent = this.agents[0];
reqPOST.Proxy = new WebProxy("127.0.0.1:9050");//порт с тором
reqPOST.ContentType = "multipart/form-data";
byte[] sentData = Encoding.GetEncoding(65001).GetBytes(..............
Answer the question
In order to leave comments, you need to log in
Tor is not an http proxy, and you are breaking into it like an HTTP proxy. Break like a SOCKS proxy and you will be happy. Just need to clarify what version of SOCKS it has: fourth or fifth ...
2 solutions
1) The first one is simple. Use the xNet library. As far as I know, work with socks is implemented there
2) If you need to make socks proxy work through WebRequest, then the solution is as follows:
Download the library link
Then create descendants of SocksHttpWebResponse and SocksHttpWebRequest inheriting from WebResponse and WebRequest as shown link
You can use it like this
WebRequest _request;
WebResponse _response;
WebProxy proxy = new WebProxy(new Uri("socks5://192.168.0.111:1080"));
if (_proxy.Address.Scheme.Contains("socks"))
_request = SocksHttpWebRequest.Create(url);
else
_request = WebRequest.Create(url);
_request.Proxy = _proxy;
// ну а дальше все как обычно
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question