Environment: Python 3.6, bs4
I am using the following code to 'webscrape' data from a local html file. The code is generally returning data as expected except instead of returning ü my code is returning ü.
I am saving the recovered data to a UTF-8 .csv file. The ü character is being displayed onto the console and into the .csv file. I am unsure where the problem lies. Is this a Unicode/charmap issue? My code? Or something else?
I would like the correct character to be returned, in this case ü
My code snippet...
# https://stackoverflow.com/questions/50308840/error-extracting-text-from-website-attributeerror-nonetype-object-has-no-attr
try:
description_elemt = result.find("div", attrs = {'class':'product-desc'}).get_text(strip=True)
except:
traceback.print_exc() # debug info to console only
description_elemt = 'No data given'
# replace 'Length' with 'length', this leaves 'Blade length: xxx mm' as one cell/element
# ref chapter 2.5, p45, Python Cookbook, 9781449340377
description_elemt = description_elemt.replace('Length', 'length')
description_elem = re.findall('[A-Z][^A-Z]*', description_elemt)
# gather the line items into one row ,separated by ,
description_elem = ','.join(description_elem)```
Thanks guys.