-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Hi found that I received an error message when I coded along with the tutorial:
Traceback (most recent call last): File "C:\Users\XXX\PycharmProjects\bs4-start\main.py", line 5, in <module> contents = file.read() ^^^^^^^^^^^ File "C:\Users\XXX\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 281: character maps to <undefined>
To fix this, I needed to add an encoding value to the BeautifulSoup Class like so:
with open("website.html", **encoding="utf-8"**) as file:
hope this helps other people encountering the same issue.