因此,我使用.findAll
(BeautifulSoup)解析了一個html頁面,並將其改名爲result
。 如果我在Python shell中鍵入result
然後按Enter鍵,我看到如預期正常的文字,但我想後處理這個結果作爲字符串對象,我注意到,str(result)
回報垃圾,像這樣的例子:如何將BeautifulSoup.ResultSet轉換爲字符串
\xd1\x87\xd0\xb8\xd0\xbb\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0</a><br />\n<hr />\n</div>
的Html頁面源代碼是utf-8
編碼
我該如何處理?
代碼基本上是這樣,如果它的事項:
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(urllib.open(url).read())
result = soup.findAll(something)
Python是2.7
顯示您的代碼請點擊這裏 – cetver