【问题标题】:Python - Extracting name of href hyperlinkPython - 提取href超链接的名称
【发布时间】:2018-04-06 21:09:23
【问题描述】:

我正在使用 Python 从网页中提取数据。该网页有许多具有 href 属性的锚标记。

例如:

<a class="identifier" href="/ICD10CM/Codes/A00-B99/A15-A19/A18-/A18.17">A18.17</a>

我可以通过使用提取这些特定标签

对于soup.find_all('a') 中的x: 打印(x)

但是,我只想提取链接的名称(示例中为 A18.17)。我该怎么做?

谢谢。

【问题讨论】:

    标签: python html python-2.7


    【解决方案1】:
    print x.text
    

    here 回答了一个类似的问题,documentation 应该会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-13
      • 2016-02-01
      • 2018-08-17
      • 1970-01-01
      • 1970-01-01
      • 2016-09-11
      • 1970-01-01
      • 2017-10-22
      相关资源
      最近更新 更多