from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# 定位所有标签 findAll, 定位第一个 find
lst = soup.findAll('a', attrs={'class': 'count-limit'}) # 是一个list
i = soup.find('a', attrs={'class': 'count-limit'}) # 一个对象
i.string # 该节点的文本内容
i['href'] # 该节点的 href 属性内容
python bs4 BeautifulSoup
于 2021-11-25 15:12:33 首次发布