べすとえふぉーと

プログラミング等のノート 

python http getでデコードエラーが出た場合に文字を無視する

UnicodeDecodeError: 'utf-8' codec can't decode byte

無視する場合は errors='ignore'をつける

response = urllib.request.urlopen(req)
charset = response.headers.get_content_charset()
if charset==None:
        charset = "utf-8"
html = response.read().decode(charset,errors='ignore')