0

Background details:
-Using atom with installed package script
-Python version is 3.8.3
-Trying to web scrape from a URL which is an online directory
-Would like to know more about this error and solve it
-image link of script and error : https://i.stack.imgur.com/QQWtE.jpg

    from bs4 import BeautifulSoup
    import requests

    url = "https://www.timesbusinessdirectory.com/company-listings"
    source_url=requests.get(url).text
    html=BeautifulSoup(source_url, 'html.parser')
    print(html.prettify())
Traceback (most recent call last):
  File "C:\Users\User\Desktop\beautiful\scrap.py", line 8, in <module>
    print(html)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u221e' in position 5103: character maps to <undefined>
  • this is my first post on stackoverflow, sorry for the formatting issues – Chow jing lun May 15 '20 at 13:46
  • Please edit your post. It's not that hard. And also share the error message – Orestis Zekai May 15 '20 at 13:57
  • Does this answer your question? [UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)](https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20). BTW, as a new user here, please take the [tour] and read [ask]. – Ulrich Eckhardt May 16 '20 at 07:25

0 Answers0