我建立Python的3.3的Python:UnicodeDecodeError錯誤:「UTF-8」編解碼器不能解碼字節...無效延續字節
使用BeautifulSoup網絡刮板但是我得到它阻止我獲得的一個問題我可以使用BeautifulSoup的有效絃樂*。那就是:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 7047: invalid continuation byte
我知道有幾十個類似的問題,但我至今沒有發現一種方法,可以幫助我來診斷什麼是錯用下面的代碼:
import urllib.request
URL = "<url>" # sorry, I cannot show the url for privacy reasons, but it's a normal html document
page = urllib.request.urlopen(URL)
page = page.read().decode("utf-8") # from bytes to <source encodings>
正如我猜測我注意到這個錯誤只發生在一些URLS而不是其他人。即使有這個相同的錯誤,我直到昨天才發現這個錯誤。然後今天我再次運行該程序,並彈出錯誤..
任何線索如何診斷錯誤?