samedi 3 octobre 2015

Retrieve and decode the content of kat.cr in Python3

Trying to retrieve and print some data from KickassTorrents (kat.cr) using this code:

source = urllib.request.urlopen("http://www.kat.cr")
text = source.read()
print (text.decode('UTF-8', 'replace'))

The result is a garbage. Note that without 'replace' it gives me an error that utf-8 codec can't decode byte in position 1, invalid start byte. Works fin on other sites, just not here. Anybody has an idea what's the problem? Thanks




Aucun commentaire:

Enregistrer un commentaire