Advertisement
Guest User

python error read data from web

a guest
Jan 24th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. Μαζί με την ".decode()" όπως την έχεις εσύ :
  2.  
  3. $ python3 requests.py
  4.  
  5. Traceback (most recent call last):
  6.   File "requests.py", line 9, in <module>
  7.     content = str(f.read().decode())
  8. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 693: invalid continuation byte
  9.  
  10. ------------------------------------------------------------------------------------------------
  11.  
  12. Χωρίς την .decode() με τον απλό παρακάτω κώδικα :
  13.  
  14. f = urllib.request.urlopen('http://stie...')
  15.  
  16. content = str(f.read())
  17. print(content)
  18.  
  19. ------------------------------------------------------------------------------------------------
  20.  
  21. Έχω το παρακάτω αποτέλεσμα ( μέρος της εξόδου ) :
  22.  
  23. target=_blank>\xc1\xea\xe1\xe4\xe7\xec\xe1\xfa\xea\xde \xd4\xe1\xf5\xf4\xfc\xf4\xe7\xf4\xe1</A><font class=\'title\'>\xd3\xd5\xcd\xc5\xd1\xc3\xc1\xc6\xcf\xcc\xc5\xcd\xcf\xc9 \xd6\xcf\xd1\xc5\xc9\xd3</font><A class=\'menu\' href="http://www.agi.com" target=_blank>agi analysis software</A><font class=\'title\'> \xc4\xc9\xca\xd4\xd5\xc1\xca\xcf\xc9 \xd4\xcf\xd0\xcf\xc9</font><A class=\'menu\' href="
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement