【问题标题】:Get element inside class with selenium使用硒获取类内的元素
【发布时间】:2021-06-05 06:03:42
【问题描述】:

我目前正在开发一个网络scraping 程序,以从带有 selenium 的 Steam 游戏中获取价格。问题是我找不到获取“data-price-final”的方法,你能帮帮我吗?

<div class="game_purchase_price price" data-price-final="1150000">
CLP$ 11.500</div>

【问题讨论】:

    标签: python html css selenium web-scraping


    【解决方案1】:

    只需对相关属性使用 get_attribute。

    value=driver.find_element_by_xpath("//div[@class='game_purchase_price price']").get_attribute("data-price-final")
    print(value)
    

    【讨论】:

      猜你喜欢
      • 2021-07-14
      • 1970-01-01
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多