【发布时间】:2015-07-18 00:05:51
【问题描述】:
我正在尝试获取一些数据,这是我的代码:
import requests
from bs4 import BeautifulSoup
url = 'http://www.privredni-imenik.com/firma/68225-a_expo'
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
g_data = soup.find_all("div", {"class":"podaci"})
for i in g_data:
some = i.text.encode('utf-8', 'ignore')
print (some)
它可以工作,但是结果如下所示:
b'A & L EXPO PREDUZE\xc4\x86E ZA PROIZVODNJU
其中\xc4\x86应该用字母Ć表示。
我怎样才能让它工作?
【问题讨论】:
-
为什么不直接打印文本?
标签: python python-3.x encoding character-encoding beautifulsoup