【问题标题】:Is it possible to scrape HTML hyperlink text, rather than just the URL?是否可以抓取 HTML 超链接文本,而不仅仅是 URL?
【发布时间】:2022-01-05 20:26:17
【问题描述】:

我正在尝试从 :https://twitchtracker.com/criticalrole/games 中抓取一些文本,以便向主播展示 twitch 付费数据分析项目中流媒体最多的游戏。

我正在尝试从表格的第一行中抓取“Dungeons & Dragons”,但到目前为止我只抓取了 href。

我的代码: table = soup2.find(id='games').select('a', limit=1) print(table)

输出 [<a href="/criticalrole/games/509577"> Dungeons & Dragons </a>]

【问题讨论】:

    标签: python html web-scraping beautifulsoup


    【解决方案1】:

    使用get_text():

    print(table[0].get_text())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-04
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 2017-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多