Gzip, HTMLAgilitypack

前端 未结 1 1850
执念已碎
执念已碎 2021-01-29 07:55

i have some problems with Gzip in HTMLAgillityPack Error - \'gzip\' is not a supported encoding name

Code:

var url = \"http://poe.trade/search/arokazuget         


        
相关标签:
1条回答
  • 2021-01-29 08:41

    You can add gzip encoding using below method.

    var url = "http://poe.trade/search/arokazugetohar";
    
    HtmlWeb webClient = new HtmlWeb();
    HtmlAgilityPack.HtmlWeb.PreRequestHandler handler = delegate (HttpWebRequest request)
    {
        request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
        request.CookieContainer = new System.Net.CookieContainer();
        return true;
     };
     webClient.PreRequest += handler;
    
     HtmlDocument doc = webClient.Load(url);
    
    0 讨论(0)
提交回复
热议问题