【发布时间】:2020-09-27 11:28:40
【问题描述】:
我正在尝试浏览此网页 (https://www.msci.com/end-of-day-data-country),从下拉菜单中选择一些选项,然后进一步单击每个国家/地区的名称以转到不同的网页。
但是我无法从页面中找到任何内容,通过 id、类、名称、xpath 进行搜索,也无法找到或切换到任何 iframe。
起初我试图通过复制 xpath 来找到 Currency 下拉列表:
!pip install selenium
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
# Example searches
wd.get("https://www.msci.com/end-of-day-data-country")
wd.find_element_by_xpath("//*[@id='templateForm:selectOneMenuCategoryCountryCurrency']")
wd.find_element_by_css_selector("#templateForm\:selectOneMenuCategoryCountryCurrency")
然后我发现问题可以链接到iframeshere,但是尝试并没有找到iframes:
wd.find_elements_by_tag_name("iframe")
如何正确访问本页内容?
【问题讨论】:
标签: python selenium selenium-webdriver iframe selenium-chromedriver