如何使用Beautiful Soup在python中编码' - '

时间:2017-03-11 07:57:13

标签: python unicode character-encoding beautifulsoup ascii

我正试图从维基百科页面中删除段落。

我收到此错误:

UnicodeEncodeError: 'charmap' codec can't encode character u'\u2013'
in position 530: character maps to <undefined>

例如,我使用了this wikipedia page并使用 BeautifulSoup requests 在Python中编写了以下脚本:

from bs4 import BeautifulSoup
import requests
soup=BeautifulSoup(r.content,"html.parser")
for i in soup.find_all("p"):
     print i.text
     print "\n"

0 个答案:

没有答案