bilgisayarkorsani.com - Forum
»
Programlama
»
C#
»
HtmlAgilityPack 'gzip,deflate' is not a supported encoding name
Mesajlar: 454
Puanlar: 8.483
Konum: Istanbul
6 Kere Teşekkür Etti.
3 Mesajına Toplam 4 Kere Teşekkür Edildi.
|
Using the HtmlAgilityPack I came across a html page that gave an exception at HtmlWeb.cs in function Get. When the line respenc = System.Text.Encoding.GetEncoding(resp.ContentEncoding); was executing and resp.ContentEncoding is "gzip" an exception is thrown say gzip is not a supported encoding name.
This is how I solved the problem:
try
{
respenc = System.Text.Encoding.GetEncoding(resp.ContentEncoding);
}
catch (Exception)
{
respenc = null;
}
and when getting the responsestream:
if (resp.ContentEncoding.ToLower().Contains("gzip"))
s = new GZipStream(s, CompressionMode.Decompress);
Now the code also works with gzip compressed pages.
Would it be possible to solve this in the offcial code?
|
|
|
|
|
|
Mesajlar: 454
Puanlar: 8.483
Konum: Istanbul
6 Kere Teşekkür Etti.
3 Mesajına Toplam 4 Kere Teşekkür Edildi.
|
Just change the following lines in HtmlWeb.cs - line 433
if ((resp.ContentEncoding != null) && (resp.ContentEncoding.Length>0))
{
try
{
respenc = System.Text.Encoding.GetEncoding(resp.ContentEncoding);
}
catch
{
respenc = null;
}
}
else
{
respenc = null;
}
I hope this will be usefull...
|
|
|
|
|
|
bilgisayarkorsani.com - Forum
»
Programlama
»
C#
»
HtmlAgilityPack 'gzip,deflate' is not a supported encoding name
Forumu Atla
Bu foruma yeni konular postalayamazsınız.
Bu forumda ki konulara yeni posta gönderemezsiniz.
Bu forumdaki postalarınızı silemezsiniz.
Bu forumdaki postalarınızı düzenleyemezsiniz.
Bu forumda anketler yaratamazsınız.
Bu forumdaki anketlere oy veremezsiniz.