selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None;Message: unexpected alert open: {Alert text : 您点击的频率过快!请稍后再试}
报错
Traceback (most recent call last): File "C:/myFiles/code/cnki/cnki_1/core/knavi.py", line 281, in <module> main() File "C:/myFiles/code/cnki/cnki_1/core/knavi.py", line 270, in main periodical(driver, i["periodical_herf"]) File "C:/myFiles/code/cnki/cnki_1/core/knavi.py", line 232, in periodical driver.get(URL) # 获取页面 File "C:\python3.6.3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "C:\python3.6.3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\python3.6.3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 241, in check_response raise exception_class(message, screen, stacktrace, alert_text) selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None Message: unexpected alert open: {Alert text : 您点击的频率过快!请稍后再试} (Session info: chrome=73.0.3683.103) (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.15063 x86_64)
解决方案:
from selenium.common.exceptions import UnexpectedAlertPresentException except UnexpectedAlertPresentException: driver.switch_to.alert.accept() driver.delete_all_cookies() time.sleep(300) continue
作者:沐禹辰
出处:http://www.cnblogs.com/renfanzi/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
出处:http://www.cnblogs.com/renfanzi/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。