我想得到含硒的hkdrates表格:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
browser = webdriver.Chrome(options=chrome_options,executable_path='/usr/bin/chromedriver')
browser.get("https://www.bochk.com/en/investment/rates/hkdrates.html")
现在该网页包含用selenium的chrome驱动程序打开的hkdrates:
browser.find_elements_by_xpath('//*[@id="form-div"]/form/div/table')
[]
browser.find_elements_by_xpath('.//table')
[]
他们两个什么都拿不到,那怎样才能拿到香港德甲的积分呢?你知道吗
要使用Selenium获取hkdrates表,因为所需元素位于
<iframe>
内,所以您必须:frame_to_be_available_and_switch_to_it()
诱导WebDriverWait。你知道吗visibility_of_all_elements_located()
诱导WebDriverWait。你知道吗您可以使用以下解决方案:
代码块:
控制台输出:
你的意思是桌子在iframe里面,你需要先换一下。您可以使用以下方法:
iframe有一个
id: iframe
对于您的
hkdrates table
,您可以使用css selector: .form_table.import-data.second-right
以下导入:
如果您的表在iframe中,请更改https://www.bochk.com/whk/rates/exchangeRatesHKD/exchangeRatesHKD-input.action?lang=en的url
相关问题 更多 >
编程相关推荐