logo
Loading...

出現Couldn't find a tree builder with the features you requested: html5lib? - Cupoy

import requestsfrom bs4 import BeautifulSoupurl = ...

出現Couldn't find a tree builder with the features you requested: html5lib?

2020/06/20 09:31 AM
Python網路爬蟲論壇
佳鈴
觀看數:0
回答數:2
收藏數:0

import requests

from bs4 import BeautifulSoup


url = 'https://www.ettoday.net/news/news-list.htm'

r = requests.get(url)


soup = BeautifulSoup(r.text, "html5lib")


for d in soup.find(class_="part_list_2").find_all('h3'):

   print(d.find(class_="date").text, d.find_all('a')[-1].text)

出現的錯誤訊息如下:

FeatureNotFound                           Traceback (most recent call last)
<ipython-input-2-a7255b1cf22c> in <module>
     5 r = requests.get(url)
     6
----> 7 soup = BeautifulSoup(r.text, "html5lib")
     8
     9 for d in soup.find(class_="part_list_2").find_all('h3'):

/srv/conda/envs/notebook/lib/python3.7/site-packages/bs4/__init__.py in __init__(self, markup, features, builder, parse_only, from_encoding, exclude_encodings, element_classes, **kwargs)
   243                     "Couldn't find a tree builder with the features you "
   244                     "requested: %s. Do you need to install a parser library?"
--> 245                     % ",".join(features))
   246
   247         # At this point either we have a TreeBuilder instance in

FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?


請問要怎麼解決呢?