记录:selenium点击“下一页”或“继续阅读”出现的错误以及解决方式

模拟浏览器爬取某些网站的时候,点击下一页或者继续阅读标签会出现

Element:ElementClickInterceptedException

如果出现这种错误,说明这个标签被隐藏了,可以采取以下两种方式解决

1、

button = driver.find_element_by_xpath('//a[@id="btn-read-all"]')
webdriver.ActionChains(driver).move_to_element(button).click(button).perform()

2、

# 获取继续阅读按钮
button = driver.find_element_by_xpath('//a[@id="btn-read-all"]')
driver.execute_script("arguments[0].click();", button)
time.sleep(2)

这两种方式都可以

你可能感兴趣的:(爬虫,自动化工具,selenium,chrome)