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-01 18:07:50 32 4
gpt4 key购买 nike

我正在使用 InstaPy,它使用 Python 和 Selenium。我按照 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')         
  • 由于太小,Chrome 似乎在某些页面的 Docker 容器中崩溃 /dev/shm 。所以你可能需要修复小/dev/shm尺寸。

  • 示例:

    sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
  • 如果您使用-v /dev/shm:/dev/shm,它也有效。共享主机的选项 /dev/shm

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

    chrome_options.add_argument('--disable-dev-shm-usage')        
<小时/>

选项卡崩溃

从选项卡崩溃Chromium 团队 的 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/60528335/

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