【发布时间】: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
例如,
<a href="wiki..." title="example"> blah </a>
title = soup.select('div > ul > li > a') # ???
我想在 [ a href=' ' title=' ' ] 中获取标题名称“example”。
如果可能,我想使用“选择”语句。
【问题讨论】:
标签: python beautifulsoup
如果我理解正确,要从链接中获取标题,您可以这样做:
# 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')
【讨论】: