美丽的汤没有href

时间:2018-09-10 19:41:27

标签: python beautifulsoup href

我是Beautiful Soup的新手,以前的堆栈溢出解决方案并没有帮助我解决问题。

我想要一个遍历表中每一行的函数,以获取在“ 0 first”类中​​找到的href。我似乎无法隔离href。我已经尝试过tds ['href'],但它会返回KeyError。

soup.find()
links = []

for tds in soup.find_all("li", {"class": "0 first"}):
    links.append(tds)
    return links

这将返回以下

<li class="0 first"><a href="/incident/271363">View Incident</a></li> 我怎样才能从每个班级获得href?

0 个答案:

没有答案
相关问题