Как обойти блокировку прокси C#? - PullRequest
0 голосов
/ 19 февраля 2020

Когда я отправляю запрос, мой прокси и учетная запись блокируются после 3-5 запросов. Я отправляю запрос через Кварц пару раз в день. Смена прокси не помогает рабочему прокси для этого сайта 1-2 из 100. Платный прокси также блокируется, или ответ типа «Время отклика с сервера на www.site.com истекло».

Что может сделать, чтобы меня не заблокировали?

 var request = await GetNewRequest(url, proxy, new CookieCollection(),login ,password);

 WebResponse response = request.GetResponse();//the proxy server is not responding. But the proxy is  working on most US sites

Где

//example ProxyHostWithPort = "123.456.78.90:3128"

    protected virtual async Task<HttpWebRequest> GetNewRequest(String Url, String ProxyHostWithPort, CookieCollection cookie,string proxyLogin=null,string proxyPassword=null)
                {
                    HttpWebRequest webReq = null;
                    WebProxy proxy = null;

                    webReq = (HttpWebRequest)WebRequest.Create(Url);

                    if ((ProxyHostWithPort != null) && (ProxyHostWithPort != ""))
                    {
                        proxy = new WebProxy(ProxyHostWithPort);
                        if (proxyLogin != null && proxyPassword != null)
                        {
                            NetworkCredential credentials = new NetworkCredential();
                            credentials.UserName = proxyLogin;
                            credentials.Password = proxyPassword;
                            proxy.Credentials = credentials;
                        }
                        webReq.Proxy = proxy;
                    }
                    else
                    {
                        webReq.Proxy = null;
                    }
                    webReq.CookieContainer = new CookieContainer();
                    if (cookie != null)
                    {
                        webReq.CookieContainer.Add(cookie);
                    }
                    webReq.UserAgent = UserAgent;
                    webReq.Accept = Accept;
                    webReq.AllowAutoRedirect = false;
                    webReq.Timeout=timeout;
                    return webReq;
                }
...