簡體   English   中英

OSError:使用未檢測到的 chromedriver 時 [WinError 6]

[英]OSError: [WinError 6] when using undetected-chromedriver

當我的 (Python) Selenium scraper 完成它的任務時,我得到了這個例外,我正在使用 undetected-chromedriver:

Exception ignored in: <function Chrome.__del__ at 0x00000241A36A6700>
    Traceback (most recent call last):   File "C:\Users\Desktop\22.12.06 Vehicle Scrapper\v2\venv\Lib\site-packages\undetected_chromedriver\__init__.py", line 769, in __del__
    self.quit()
    File "C:\Users\Desktop\22.12.06 Vehicle Scrapper\v2\venv\Lib\site-packages\undetected_chromedriver\__init__.py", line 758, in quit
    time.sleep(0.1)
OSError: [WinError 6] Controlador no válido

這不會影響腳本的功能,但我更希望在控制台中干凈關閉。

您可以使用SeleniumBase來解決這個問題,它有一個undetected-chromedriver模式,具有更好的錯誤處理和其他改進:

首先pip install seleniumbase ,然后以python作為基本示例運行:

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.open("https://nowsecure.nl/#relax")
    try:
        sb.assert_text("OH YEAH, you passed!", "h1", timeout=8.75)
        sb.post_message("Selenium wasn't detected!", duration=2.8)
        sb._print("\n Success! Website did not detect Selenium! ")
    except Exception:
        sb.fail('Selenium was detected!')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM