1

I'm trying to get the HTML source code from a web page with this code:

HttpClient httpClient = new();
httpClient.DefaultRequestHeaders.Add("user-agent", "search app");

var sourceCode = await httpClient.GetStringAsync(url);

I tried with many web pages, and I didn't have any problem. Everything works fine, and the result is the HTML content of the web page as a string.

But now I'm trying with Amazon (in the URL use for example "https://www.amazon.com") and the result came encrypted. I can't even copy the result to show you.

What is happening and how can I solve this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
inpo
  • 11
  • 1
  • 5
    I very much doubt that it's *encrypted*. I think it's much more likely that it's compressed. See https://stackoverflow.com/questions/20990601 for an option for automatic decompression. – Jon Skeet Aug 23 '23 at 19:29

1 Answers1

0

Solved! Thanks to Jon Skeet who commented:

I very much doubt that it's encrypted. I think it's much more likely that it's compressed. See Decompressing GZip Stream from HTTPClient Response for an option for automatic decompression.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
inpo
  • 11
  • 1