我想写一个简单的网页刮脚本,所以我写了这段代码,我得到一个错误。Python web刮(请求,BeautifulSoup)
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'? –
我试过,但它因此未工作 – Yya09