所以我試圖解析網站的使用Python HTML和有一個麻煩人物u011f是提供了以下錯誤:如何處理無效的unicode BeautifulSoup而不轉換爲utf-8?
Function call: soup = BeautifulSoup(response, "html.parser")
print (soup)
Error: UnicodeEncodeError: 'charmap' codec can't encode character '\u011f'
如果我這樣做,而不是和編碼成UTF-8,
soup = BeautifulSoup(response, "html.parser").encode('utf-8')
它刪除錯誤,但我不能這樣做,因爲我稍後調用find函數,它必須在unicode中。如果我編碼成UTF-8後調用查找功能,我收到以下錯誤:
Function call: worksTable = soup.find('tbody', attrs={'id': 'some_id'})
Error: TypeError: find() takes no keyword arguments
我已經花了這段代碼小時,不能在這裏找到適合我的情況下,任何的答案。任何幫助,將不勝感激。
的可能的複製(http://stackoverflow.com/questions/ 34694858/beautifulsoup4-stripped-strings-giving-me-byte-objects) – styvane