html - Java: Reading from a URL produces gibberish -


So I'm trying to read html code from kickass.to (it works fine on other sites), But all I got is some weird gossip my code:

  BufferedReader = new BufferedReader (New InputStreamReader (New URL ("http://kickass.to/") .openstream ())); String s = ""; While ((s = in.readLine ()) = null) System.out.println (s); In.close ();  

For example: Enter image details here Does anyone know Why does that make it? Thanks!

The problem here is a server that is probably not correctly configured, because it's its The response gives gzip compressed, even if the client does not send a approved-encoding: gzip header.

So what you see is the compressed version of the page. To decompress it, pass it through one:

  BufferedReader = new BufferedReader (new InputStreamReader (new GZIPInputStream (new URL ("http://kickass.to/"). Openstream ())));  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -