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

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)

这两种方式都可以

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐