欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

HtmlAgilityPack HtmlWeb.Load() 不支持 gzip 的解决方法

程序员文章站 2024-02-29 09:45:58
...
            _htmlWeb = new HtmlWeb();
            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;
            };
            _htmlWeb.PreRequest += handler;
相关标签: gzip