【发布时间】:2020-01-06 15:20:27
【问题描述】:
我正在尝试使用 BeautifulSoup 从 HTML 页面中获取名称:
import urllib.request
from bs4 import BeautifulSoup
nightbot = 'https://nightbot.tv/t/tonyxzero/song_requests'
page = urllib.request.urlopen(nightbot)
soup = BeautifulSoup(page, 'html5lib')
list_item = soup.find('strong', attrs={'class': 'ng-binding'})
print (list_item)
但是当我打印print(list_item) 时,我得到一个none 作为回复。有办法解决吗?
【问题讨论】:
-
试试 print(soup.prettify()) 看看你认为应该存在的标签是否真的存在。
-
标签不存在。使用 Maaz 的解决方案有效。谢谢! :)
标签: python beautifulsoup scrapy