HTTPWebResponse + StreamReader Very Slow

前端 未结 9 1234
粉色の甜心
粉色の甜心 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:17

    I had the same problem, but when I sat the HttpWebRequest's Proxy parameter to null, it solved the problem.

    UriBuilder ub = new UriBuilder(url);
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create( ub.Uri );
    request.Proxy = null;
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
    0 讨论(0)
  • 2020-12-01 02:25

    I had problem the same problem but worst. response = (HttpWebResponse)webRequest.GetResponse(); in my code delayed about 10 seconds before running more code and after this the download saturated my connection.

    kurt's answer defaultProxy enabled="false"

    solved the problem. now the response is almost instantly and i can download any http file at my connections maximum speed :) sorry for bad english

    0 讨论(0)
  • 2020-12-01 02:26

    Try to add cookie(AspxAutoDetectCookieSupport=1) to your request like this

    request.CookieContainer = new CookieContainer();         
    request.CookieContainer.Add(new Cookie("AspxAutoDetectCookieSupport", "1") { Domain = target.Host });
    
    0 讨论(0)
提交回复
热议问题