selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None;Message: unexpected ale...

报错

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

 

转载于:https://www.cnblogs.com/renfanzi/p/10734800.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值