HTTPWebResponse + StreamReader Very Slow

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

    HttpWebRequest may be taking a while to detect your proxy settings. Try adding this to your application config:

    
      
        
        
        
      
    
    

    You might also see a slight performance gain from buffering your reads to reduce the number of calls made to the underlying operating system socket:

    using (BufferedStream buffer = new BufferedStream(stream))
    {
      using (StreamReader reader = new StreamReader(buffer))
      {
        pageContent = reader.ReadToEnd();
      }
    }
    

提交回复
热议问题