【发布时间】:2019-04-21 07:41:46
【问题描述】:
我正在尝试制作一张表格,在其中收集来自this page 的每个作曲家的所有作品,并通过添加“分数”来排列它们,例如第 300 名得 1 分,第 10 名得 290 分等。使用 Python 脚本。
但是,BeautifulSoup 似乎找不到 li 元素。我究竟做错了什么?页面HTML截图:https://gyazo.com/73ff53fb332755300d9b7450011a7130
我已经尝试过使用soup.li、soup.findAll("li") 和soup.find_all("li"),但都返回“none”或类似的结果。打印 soup.body 确实会返回正文,所以我想我确实有一个 HTML 文档。
from bs4 import BeautifulSoup as bsoup
import requests
link = "https://halloffame.classicfm.com/2019/"
response = requests.get(link)
soup = bsoup(response.text, "html.parser")
print(soup.li)
我希望这会给我至少一个li 项目,但它却返回None。
【问题讨论】:
-
您是否尝试过打印
response.text以查看实际得到的结果?
标签: python html web-scraping beautifulsoup