【发布时间】:2016-02-21 22:27:18
【问题描述】:
我正在尝试编写一个简单的网络抓取脚本,所以我编写了这段代码,但出现了错误。
import requests
from bs4 import BeautifulSoup
r = requests.get('http://the website that I need.com')
soup = BeautifulSoup(r.content)
print(soup.prettify())
我收到一条错误消息:
Traceback (most recent call last):
File "course.py", line 18, in <module>
print(soup.prettify())
File "C:\Python34\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u203a' in position
32558: character maps to <undefined>
我正在使用 Python 3.4.0
那么谁能告诉我发生了什么?
【问题讨论】:
-
尝试使用
r.text代替r.content? -
我试过但没用
标签: python beautifulsoup python-requests