gpt4 book ai didi

python - webdriver.get() 引发 TimeoutException

转载 作者:太空宇宙 更新时间:2023-11-03 19:51:47 26 4
gpt4 key购买 nike

我每天将 selenium 与 celery 和 mitmproxy 结合使用来扫描多个网站的 cookie。昨天,我的应用程序由于以下异常而崩溃:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 648, in __protected_call__
return self.run(*args, **kwargs)
File "/home/myapplication/myapplication/api/tasks.py", line 24, in scan_periodically
x.startscanner(executor=Scan.PERIODICALLY)
File "/home/myapplication/myapplication/api/scanner.py", line 204, in startscanner
self.browser_list[self.browser_list_place].get(self.website.url)
File "/home/myapplication/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/home/myapplication/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/myapplication/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: headless chrome=76.0.3809.100)

我使用来自 selenium 的 python api,Python 版本为 3.7.3,selenium api 版本为 3.141.0,Google Chrome 76.0.3809.100 与 chromedriver 版本为 76.0.3809.68。

为什么 webdriver get() 方法会引发 TimeoutException?

最佳答案

尝试使用此参数来避免/覆盖超时,我在我的 Selenium 库中找到了它们

import socket
from selenium.common.exceptions import TimeoutException

#Init your browser, then
#...

socket.setdefaulttimeout(int(60))

your_browser_driver.set_page_load_timeout(60)

关于python - webdriver.get() 引发 TimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59784830/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com