使用Python的Selenium库从网站访问此值

发布于 2025-02-13 11:25:04 字数 570 浏览 1 评论 0 原文

我能够使用硒来创建驱动程序,并使用它登录此站点并加载此页面

< img src =“ https://i.sstatic.net/fakof.jpg” alt =“在此处输入图像说明”>

我应该如何尝试访问这个2.8±0.5值?我能够使用&lt; iframe&gt; 使用,

iframe = WebDriverWait(driver, timeout=10).until(EC.presence_of_all_element_located((By.TAG_NAME,'iframe')))

但是当我这样做时,

iframe.find_element(By.CLASS_NAME,'src')))

我无法获得任何东西。

如何获得此值有任何解决方法吗?我应该尝试先转到SRC链接吗? Selenium是正确的库吗?谢谢。

I was able to use selenium to create a driver, and use it to login to this site and load this page

enter image description here

How should I go about trying to access this 2.8 ± 0.5 value? I was able to access the <iframe> by using

iframe = WebDriverWait(driver, timeout=10).until(EC.presence_of_all_element_located((By.TAG_NAME,'iframe')))

but then when I did

iframe.find_element(By.CLASS_NAME,'src')))

I couldn't get anything.

Is there any workaround for how to get this value? Should I try to go to the src link first? Is selenium the correct library to attempt this? Thank you.

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

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

发布评论

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

评论(1

天气好吗我好吗 2025-02-20 11:25:04

在找到其下的元素之前,您需要切换到&lt; iframe&gt; 。您可以使用 frame_to_be_available_and_switch_to_it 为此,

WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it((By.TAG_NAME,'iframe')))

您还可以使用 ID 或 name name by by

WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it('MLVALUEDFT_dielectric_total'))

,现在使用 > driver.find_element(...)找到元素。

要退出&lt; iframe&gt; 使用 driver.switch_to.default_content()

You need to switch to the <iframe> before locating elements under it. You can use frame_to_be_available_and_switch_to_it for that

WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it((By.TAG_NAME,'iframe')))

You can also use the id or name attributes without By

WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it('MLVALUEDFT_dielectric_total'))

And now use driver.find_element(...) to locate the element.

To switch back out of the <iframe> use driver.switch_to.default_content()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文