尝试从网站获取值,但它给出 0.00 而不是不为零的实际值

发布于 2025-01-15 19:58:07 字数 506 浏览 1 评论 0原文

这是我尝试用 python selenium 获取的值:

<div class="price">$<div style="display: inline-block;">24.42</div></div>

这是我的代码:

Value = browser.find_elements(By.CLASS_NAME, ('price'))
print(Value[1].text)

这是我在 Atom 控制台中的输出:

$
0.00

重要的是要知道: 我尝试每分钟左右获取该数字的更改。 “价格”类在网站上显示两次,这就是我选择第二个元素(又名 [1])的原因。

我的问题: 如何正确编码以获得 24.42 的值? (“Value”的类型是div。) 如果我得到了这个值,我可以使用相同的代码来获取另一个值来比较它们。

感谢您的回答:)

here is the value i try to grab with python selenium:

<div class="price">
lt;div style="display: inline-block;">24.42</div></div>

Here is my code:

Value = browser.find_elements(By.CLASS_NAME, ('price'))
print(Value[1].text)

Here is my output in Atom console:

$
0.00

Important to know: That number i try to get changes every minute or so.
The class "price" shows two times on the website, thats why I choose the second element aka [1].

My question:
How to code this correctly, to get the value of 24.42? (The type of "Value" is div.)
If I get the value, I can use the same code to get another vaule to compare them.

Thanks for your answers :)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文