gpt4 book ai didi

python - 未知错误 : session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium

转载 作者:行者123 更新时间:2023-12-05 07:00:43 31 4
gpt4 key购买 nike

我正在使用使用 Python 和 Selenium 的 InstaPy。我按 Cron 启动脚本,有时它会崩溃。所以它真的很不规则,有时它会很好地贯穿始终。我也已经在 GitHub Repo 上发帖,但没有在那里得到答案,所以我现在在这里问是否有人知道原因。

这是一个 digital ocean ubuntu 服务器,我在 headless 模式下使用它。驱动程序版本在日志中可见。以下是错误消息:

ERROR [2018-12-10 09:53:54] [user]  Error occurred while deleting cookies from web browser!
b'Message: invalid session id\n (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)\n'
Traceback (most recent call last):
File "/root/InstaPy/instapy/util.py", line 1410, in smart_run
yield
File "./my_config.py", line 43, in <module>
session.follow_user_followers(['xxxx','xxxx','xxxx','xxxx'], amount=100, randomize=True, interact=True)
File "/root/InstaPy/instapy/instapy.py", line 2907, in follow_user_followers
self.logfolder)
File "/root/InstaPy/instapy/unfollow_util.py", line 883, in get_given_user_followers
channel, jumps, logger, logfolder)
File "/root/InstaPy/instapy/unfollow_util.py", line 722, in get_users_through_dialog
person_list = dialog_username_extractor(buttons)
File "/root/InstaPy/instapy/unfollow_util.py", line 747, in dialog_username_extractor
person_list.append(person.find_element_by_xpath("../../../*")
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 351, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 659, in find_element
{"using": by, "value": value})['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
(Session info: headless chrome=70.0.3538.110)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/InstaPy/instapy/instapy.py", line 3845, in end
self.browser.delete_all_cookies()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 878, in delete_all_cookies
self.execute(Command.DELETE_ALL_COOKIES)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: headless chrome=71.0.3578.80)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)

知道可能是什么原因以及如何解决吗?

感谢您的投入。还有来自 http://treestones.ch/ 的人帮助我。

最佳答案

尽管您看到的错误是:

Error occurred while deleting cookies from web browser!
b'Message: invalid session id\n (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)\n'

主要的异常(exception)是:

selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed

您的代码试验会给我们一些线索,告诉我们哪里出了问题。


解决方案

这个问题有多种解决方案。然而根据UnknownError: session deleted because of page crash from tab crashed此问题可以通过以下任一解决方案解决:

  • 添加以下chrome_options:

    chrome_options.add_argument('--no-sandbox')         
  • 由于 /dev/shm 太小,Chrome 似乎在某些页面上的 Docker 容器中崩溃。因此,您可能需要修复较小的 /dev/shm 大小。

  • 一个例子:

    sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
  • 如果您使用 -v/dev/shm:/dev/shm 选项共享 host /dev/shm

  • 另一种让它工作的方法是将 chrome_options 添加为 --disable-dev-shm-usage。这将强制 Chrome 使用 /tmp 目录。这可能会减慢执行速度,因为将使用磁盘而不是内存。

    chrome_options.add_argument('--disable-dev-shm-usage')        

标签页崩溃

from tab crashedChromium Team 的 WIP(进行中)已经有一段时间了,这与 Linux 相关试图始终将/dev/shm 用于不可执行的内存。以下是引用资料:


引用

您可以在以下位置找到一些相关讨论:

关于python - 未知错误 : session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64065873/

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