BeautifulSoupとurllib2を使ってウェブサイトからスペイン語のテキストを取得しようとしています。私は現在、これを得る:¡Hola! ¿Cómo estás?
。 私は、関連するスレッド上で見てきたさまざまなUnicode関数を適用しようとしたが、何も私の問題のために動いていないようにみえ:BeautifulSoup:スペイン語の文字を削る
# import the main window object (mw) from aqt
from aqt import mw
# import the "show info" tool from utils.py
from aqt.utils import showInfo
# import all of the Qt GUI library
from aqt.qt import *
from BeautifulSoup import BeautifulSoup
import urllib2
wiki = "http://spanishdict.com/translate/hola"
page = urllib2.urlopen(wiki)
soup = BeautifulSoup(page)
dictionarydiv = soup.find("div", { "class" : "dictionary-neodict-example" })
dictionaryspans = dictionarydiv.contents
firstspan = dictionaryspans[0]
firstspantext = firstspan.contents
thetext = firstspantext[0]
thetextstring = str(thetext)
'print thetextstring'は、UTF-8端末の場合にのみ、@FranciscoCouzoのようになります。 –
OPはWindows上にある可能性があります。 –