【发布时间】:2019-05-27 10:30:56
【问题描述】:
我尝试使用 Selenium 和 chromedriver 从 https://edm.com/news 的多个页面中抓取文章,并在尝试点击“查看更多”按钮时遇到多个错误。关于我可以尝试什么的任何想法?
我尝试过使用 ActionChains.move_to_element(..).click.perform() 还尝试了多次 time.sleep 调用或 WebDriverWait.until... 似乎没有任何效果。
start_url = "https://edm.com/news"
browser = webdriver.Chrome(executable_path='chromedriver.exe', options=self.option)
browser.get(self.start_url)
# Wait max 10 secs for page to load
timeout = 10
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((By.XPATH,'//*[@id="lyra-wrapper"]/div/div[3]/section/'
'div[2]/section[2]/section/div/button')))
time.sleep(2)
button = browser.find_elements(By.XPATH, '//*[@id="lyra-wrapper"]/div/div[3]/section/'
'div[2]/section[2]/section/div/button')[0]
button.click()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (508, 4270)
(Session info: chrome=74.0.3729.169)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.17763 x86_64)```
【问题讨论】:
标签: python python-3.x web-scraping selenium-chromedriver