【问题标题】:How can I get title name in <a href=' ' title = ' '></a> using BeautifulSoup如何使用 BeautifulSoup 在 <a href=' ' title = ' '></a> 中获取标题名称
【发布时间】:2021-01-10 22:10:54
【问题描述】:

例如,

<a href="wiki..." title="example"> blah </a>
title = soup.select('div > ul > li > a') # ???

我想在 [ a href=' ' title=' ' ] 中获取标题名称“example”。

如果可能,我想使用“选择”语句。

【问题讨论】:

标签: python beautifulsoup


【解决方案1】:

如果我理解正确,要从链接中获取标题,您可以这样做:

# if you have a link extracted
link = soup.find('a', {'class': 'whatever the class name is'})

# then you can do this to get the title
title = link.get('title')

【讨论】:

    猜你喜欢
    • 2021-01-05
    • 1970-01-01
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多