【问题标题】:Extract href from Beautiful soup tag [duplicate]从美丽的汤标签中提取href [重复]
【发布时间】: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


    【解决方案1】:

    这应该可以帮助你:

    href = col.find('a')['href']
    
    print(href)
    

    输出:

    /english/js/au/
    

    【讨论】:

      猜你喜欢
      • 2020-03-17
      • 2012-07-16
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 2019-11-07
      相关资源
      最近更新 更多