HTTPWebResponse + StreamReader Very Slow

前端 未结 9 1253
粉色の甜心
粉色の甜心 2020-12-01 01:47

I\'m trying to implement a limited web crawler in C# (for a few hundred sites only) using HttpWebResponse.GetResponse() and Streamreader.ReadToEnd() , also tried using Strea

9条回答
  •  甜味超标
    2020-12-01 02:11

    I found the Application Config method did not work, but the problem was still due to the proxy settings. My simple request used to take up to 30 seconds, now it takes 1.

    public string GetWebData()
    {
                string DestAddr = "http://mydestination.com";
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                WebProxy myProxy = new WebProxy();
                myProxy.IsBypassed(new Uri(DestAddr));
                myWebClient.Proxy = myProxy;
                return myWebClient.DownloadString(DestAddr);
    }
    

提交回复
热议问题