【发布时间】:2020-10-14 04:40:39
【问题描述】:
我正在学习如何在 Python 中使用 BeautifulSoup 库,为了练习,我正在尝试从这个 Wikipedia 页面中删除流派标题: https://en.wikipedia.org/wiki/List_of_jazz_genres
我已经能够在我的代码中做到这一点:
from bs4 import BeautifulSoup
html = open("wiki-jazz.html", encoding="utf=8")
soup = BeautifulSoup(html, "html.parser")
table = soup.find_all("table")[1]
td = table.find_all("td")
print(td)
table[1] 包含我要访问的数据。更具体地说,我真的只需要位于此标题属性中的数据:
</td>, <td><a href="/wiki/West_Coast_jazz" title="West Coast jazz">West Coast jazz</a>
我一直在琢磨如何提取这些信息。我看过这里的其他帖子,但不能完全到达那里。 谢谢。
【问题讨论】: