Gzip,HTMLAgilitypack [英] Gzip, HTMLAgilitypack
本文介绍了Gzip,HTMLAgilitypack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在HTMLAgillityPack中使用Gzip遇到了一些问题 错误-'gzip'不是受支持的编码名称
i have some problems with Gzip in HTMLAgillityPack Error - 'gzip' is not a supported encoding name
代码:
var url = "http://poe.trade/search/arokazugetohar";
var web = new HtmlWeb();
var htmldoc = web.Load(url);
推荐答案
您可以使用以下方法添加gzip编码.
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);
这篇关于Gzip,HTMLAgilitypack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文