简体   繁体   English

使用 python 中的 selenium 库从网站访问此值

[英]Accessing this value from a website using the selenium library in python

I was able to use selenium to create a driver, and use it to login to this site and load this page我能够使用 selenium 创建驱动程序,并使用它登录到该站点并加载此页面

在此处输入图像描述

How should I go about trying to access this 2.8 ± 0.5 value?我应该如何尝试访问这个 2.8 ± 0.5 值? I was able to access the <iframe> by using我能够通过使用访问<iframe>

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?我应该先尝试去 src 链接吗? Is selenium the correct library to attempt this? selenium 是尝试这个的正确库吗? Thank you.谢谢你。

You need to switch to the <iframe> before locating elements under it.您需要先切换到<iframe> ,然后再在其下定位元素。 You can use frame_to_be_available_and_switch_to_it for that您可以为此使用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')))

You can also use the id or name attributes without By您也可以使用不带Byidname属性

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.现在使用driver.find_element(...)来定位元素。

To switch back out of the <iframe> use driver.switch_to.default_content()要退出<iframe>使用driver.switch_to.default_content()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 python 中的 selenium 从网站获取价值 - Get value from a website using selenium in python 使用 Selenium 和 Python 从动态网站获取元素值 - Get element value from dynamic website using Selenium and Python 使用 Selenium 和 Python 从网站上抓取表格 - Scraping tables from website using Selenium and Python 使用python从网站访问数据会产生不完整的网站数据 - Accessing data from website using python yield incomplete website data 如何从具有特殊设置的网站上使用Selenium从下拉列表中选择一个值-Python - How to select a value from a drop-down using Selenium from a website with special setting- Python 在Python中使用硒访问按钮 - Accessing button using selenium in Python 在python中使用代理访问网站 - Accessing website using proxy in python 为网站后端实现 Selenium 库 Python - Implement the Selenium library Python for a website backend 如何使用 python、selenium 和 chromedriver 从网站中提取此值 - how can i extract this value from a website, with python, selenium and chromedriver Your requested host "localhost" could not be resolved by DNS error accessing website using Selenium Python - Your requested host "localhost" could not be resolved by DNS error accessing website using Selenium Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM