【问题标题】:Scraping specific attribute in tr tag在 tr 标签中抓取特定属性
【发布时间】:2019-11-26 17:13:47
【问题描述】:
allId=soup.find_all("tr","data-id")

我只取 data-id 的值。我怎样才能刮掉这些标签?

【问题讨论】:

    标签: python-3.x web-scraping beautifulsoup scrape


    【解决方案1】:

    要获取 data-id 的值,试试这个。

    allId=soup.find_all("tr",attrs={"data-id" : True})
    for item in allId:
        print(item['data-id'])
    

    您也可以使用 css 选择器。

    allId=soup.select("tr[data-id]")
    for item in allId:
        print(item['data-id'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-18
      • 1970-01-01
      • 2013-07-01
      • 2019-09-03
      相关资源
      最近更新 更多