UnicodeEncodeError:'charmap'编解码器无法对位置4297中的字符'\ u221e'进行编码:字符映射为<undefined>

时间:2020-05-15 13:46:08

标签: python web-scraping

背景详细信息:
-使用带有已安装软件包脚本的原子
-Python版本为3.8.3
-尝试从作为联机目录的URL进行网络抓取
-想了解更多有关此错误的信息并解决该错误
-脚本和错误的图像链接: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>

0 个答案:

没有答案