find_elements with get_atributes('innerhtml&quort;)

发布于 2025-02-13 14:50:56 字数 518 浏览 2 评论 0原文

我有以下情况,

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")

到目前为止,我将获得260个钥匙的列表,还可以! 但是,我需要这个简化的列表,只有文本

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f").get_attribute("innerHTML")

有可能获得上面的类似内容?使用 find_element 它可以正常工作。 find_element s 不起作用。

一个具有[x] .TEXT的循环太慢。 我用一个简单的数组对其进行了测试,而没有“ .TEXT”,并且更快的速度是1000倍。

I have the following situation

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")

I get list with 260 keys, So far, okay!
However, I need this simplified list, with just the text

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f").get_attribute("innerHTML")

Is there any possibility to get something like this above? With find_element it works fine.
find_elementS not work.

A loop with values[x].text is too slow.
I tested it with a simple array, without the ".text" and it's 1000x faster.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪落纷纷 2025-02-20 14:50:56

尝试:

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")
for value in values:
    v = value.get_attribute("innerHTML")

Try:

values = driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")
for value in values:
    v = value.get_attribute("innerHTML")
感悟人生的甜 2025-02-20 14:50:56

提取 innerhtml 或来自所有匹配元素的文本,您可以使用列表理解 您可以使用以下任何一个 定位器策略

  • 使用 <>

    代码> get_attribute(“ innerhtml”)

      print([[my_elem.get_attribute(“ innerhtml”)for driver.find_elements中的my_elem(by.class_name,“ roulette-histore-item __value-textsipsi-textsiwxwxwvflm3f”)))
     

  • 使用 text

      print([my_elem.text for my_elem in driver.find_elements(by.class_name,“ Roulette-histore-item __value-textsiwxwxwvflm3ohr_ums23f”))))))))))))))))))))
     

To extract the innerHTML or the texts from all the matching elements you can use list comprehension and you can use either of the following locator strategies:

  • Using get_attribute("innerHTML"):

    print([my_elem.get_attribute("innerHTML") for my_elem in driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")])
    
  • Using text:

    print([my_elem.text for my_elem in driver.find_elements(By.CLASS_NAME, "roulette-history-item__value-textsiwxWvFlm3ohr_UMS23f")])
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文