[問題] 求救 ...困在編碼問題
想請教各位高手
我有個input.txt 我很確定他是用utf-8儲存的
但是用以下的beautiful soup 處理 strip tag
卻還是亂碼 想請問是不是哪裡寫錯了 謝謝
import requests
from bs4 import BeautifulSoup
res = requests.get('http://localhost/input.txt',verify=False)
obj=bytes(res.text, "utf-8")
UTF8str=obj.decode('utf-8', 'ignore')
soup = BeautifulSoup(UTF8str, "html.parser")
text = soup.getText()
print(text)
但是出來 還是亂碼
我是照著書打的 實在不知道問題出在哪
感謝各位高手 ....orz
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.14.99
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1472565827.A.D8A.html
推
08/30 22:19, , 1F
08/30 22:19, 1F
※ 編輯: imimi (180.217.14.99), 08/30/2016 22:26:02
推
08/31 00:07, , 2F
08/31 00:07, 2F
→
08/31 05:50, , 3F
08/31 05:50, 3F
→
08/31 05:50, , 4F
08/31 05:50, 4F
→
03/10 17:39, , 5F
03/10 17:39, 5F