Zi 字媒體
2017-07-25T20:27:27+00:00
# BeautifulSoup 常用的網頁解析器
BeautifulSoup(html, "html.parser") # → 速度中等,容錯率強,python內建資料庫
BeautifulSoup(html, "lxml") # → 速度快,但須裝C語言套件
BeautifulSoup(html, "xml") # → 速度快,但須裝C語言套件
BeautifulSoup(html, "html5lib") # → 速度慢,容錯率最強,不須安裝額外套件
# 常見 error
BeautifulSoup: object of type 'Response' has no len()
# 解決方法如下:
res = requests.get(url).content
寫了
5860316篇文章,獲得
23313次喜歡