【发布时间】:2016-06-13 18:47:35
【问题描述】:
我正在尝试从使用 ajax 加载数据的站点中提取一些数据,为此我正在使用 selenium 和 python。我想单击在 ajax 页面加载后出现的链接。 我什至放了 python 的 sleep 功能,让页面完全加载,但仍然无法点击。每次“selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素”时都会出现此错误。请参阅我编写的以下代码。 谢谢
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import time
import subprocess
from selenium.webdriver.chrome.options import Options
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "C:/Users/212553509/Desktop/WHO"}
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "C:/python27/Scripts/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
driver.get("http://apps.who.int/gho/data/node.home")
time.sleep(20)
driver.find_element_by_link_text('node.main.484?lang=en').click()
【问题讨论】:
标签: python ajax selenium web-scraping selenium-chromedriver