如何從文檔中獲取西里爾字符串?如何從文檔中獲取西里爾字符串
我有休耕代碼:
import urllib
from BeautifulSoup import BeautifulSoup
page = urllib.urlopen("http://habrahabr.ru/")
soup = BeautifulSoup(page.read())
for topic in soup.findAll(True, 'topic'):
print topic
print
raw_input()
有網站,但蟒蛇顯示錯誤的字符上西里爾字。
對於這個問題的任何幫助,我都會很有幫助。
PS。
我改變
soup = BeautifulSoup(page.read())
到
soup = BeautifulSoup(page.read(), fromEncoding="utf-8")
,仍然沒有結果...
抓住這個功能,但我什麼,我需要在我的例子中做?我試圖轉換 'page.read()。decode('utf8')' 但沒有結果... – Mirgorod 2011-02-24 23:04:49
嗯,這很奇怪,但只有一個這些是正常顯示...其他項目是錯誤的字符。 .. – Mirgorod 2011-02-24 23:07:34