I am trying to get html from a website and write it to a html document. I opened the document with
open('index.html', 'w').
I got the html with:
def steal_html(self):
url=self.search_bar.get()
with open('index.html', 'w') as FILE:
html = requests.get(url).text
FILE.write(html)
# this is from a class
but I keep getting this error
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\pc_name\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Users\pc_name\Desktop\os\main.py", line 19, in steal_html
FILE.write(html)
File "C:\Users\pc_name\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 182826-182828: character maps to <undefined>
Thanks