【发布时间】:2021-02-08 10:14:00
【问题描述】:
>>> type(col)
<class 'bs4.element.Tag'>
>>> col
<td><a href="/english/js/au/">Detail</a></td>
有人可以帮我从上述数据中干净地提取 python href 作为字符串吗?我想将路径“/english/js/au/”作为字符串。
【问题讨论】:
标签: python beautifulsoup
>>> type(col)
<class 'bs4.element.Tag'>
>>> col
<td><a href="/english/js/au/">Detail</a></td>
有人可以帮我从上述数据中干净地提取 python href 作为字符串吗?我想将路径“/english/js/au/”作为字符串。
【问题讨论】:
标签: python beautifulsoup
这应该可以帮助你:
href = col.find('a')['href']
print(href)
输出:
/english/js/au/
【讨论】: