0

Possible Duplicate:
Characters in string changed after downloading HTML from the internet

To reproduce my issue have a look a the following code snippet:

const string url = "http://serienjunkies.org/serie/glee/";
var webclient = new WebClient();
var source = webclient.DownloadString(url);
Console.WriteLine(source.Substring(0, 200);

Sometimes (with absolutely the same code) I get the correct html source and othertimes just an unreadable string with odd characters. If you get the one - wait some seconds up to one minute - then you will get the other.

Expected result:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...

The other result (copy, paste from cmd):

▼      ♥????????y]2?? em§?.f♦∟3Hf??J?XRM*???%??9 Gf¶##R1p?-??;?♥???♀???U?M?I?s &?#9???⌂?????fg????o????????????;}-????v⌂???^go????????zu???????tD?u^M?h:?
...

Thank you.

Kind regards, Danny

Community
  • 1
  • 1
dannyyy
  • 1,784
  • 2
  • 19
  • 43

1 Answers1

2

Basically the server is delivering content in a compressed (GZip) format.

The answer here Characters in string changed after downloading HTML from the internet will give you a replacement downloader that will handle compressed and uncompressed files.

Community
  • 1
  • 1
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202