示例#1
0
 public string DownloadGzipString(string siteUrl)
 {
     using (var wc = new GZipWebClient())
     {
         wc.Headers[HttpRequestHeader.AcceptEncoding] = "gzip";
         wc.Headers[HttpRequestHeader.UserAgent]      = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0";
         wc.Headers[HttpRequestHeader.Referer]        = @"https://shop.wot.360.cn/main";
         wc.Encoding = Encoding.UTF8;
         string payload = wc.DownloadString(siteUrl);
         return(payload);
     }
 }
示例#2
0
 public HtmlDocument DownloadGzipHtml(string siteUrl)
 {
     using (var wc = new GZipWebClient())
     {
         wc.Headers[HttpRequestHeader.AcceptEncoding] = "gzip";
         wc.Headers[HttpRequestHeader.UserAgent]      = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0";
         wc.Encoding = Encoding.UTF8;
         string html          = wc.DownloadString(siteUrl);
         var    htmldocObject = new HtmlDocument();
         htmldocObject.LoadHtml(html);
         return(htmldocObject);
     }
 }