Gzip, HTMLAgilitypack

前端 未结 1 1849
执念已碎
执念已碎 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)
提交回复
热议问题