小编Dal*_*ump的帖子

未检测到的 Chromedriver,AttributeError:“ChromeOptions”对象没有属性“headless”

当我运行 Python Selenium 脚本打开网页时出现错误。我尝试卸载并重新安装 selenium、chromeautoinstaller 和未检测到的 chromedriver。我也尝试添加option.add_argument('--headless'). 这些都没有成功,错误仍然存​​在。

这是我的代码:

    def driverInit():
        option = uc.ChromeOptions()
        option.add_argument("--log-level=3")
    
        prefs = {"credentials_enable_service": False,
                 "profile.password_manager_enabled": False,
                 "profile.default_content_setting_values.notifications": 2
                 }
        option.add_experimental_option("prefs", prefs)
        driverr = uc.Chrome(options=option)
        return driverr
    
    def driverInitBuffMarket():
        option = uc.ChromeOptions()
        option.add_argument(
             rf'--user-data-dir=C:\Users\{os.getlogin()}\AppData\Local\Google\ChromeBuff\User Data')  # e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
        option.add_argument(r'--profile-directory=Default')
        driverr = uc.Chrome(options=option)
        return driver
Run Code Online (Sandbox Code Playgroud)

错误发生在倒数第二行,driverr = uc.Chrome(options=option)

这是错误:

Traceback (most recent call last):
  File "C:\Users\kumpd\OneDrive\Desktop\All Market Bots\BuffMarket Purchase Bot Testing\main.py", line 266, in <module>
    start_buy_monitoring()
  File "C:\Users\kumpd\OneDrive\Desktop\All Market Bots\BuffMarket Purchase Bot Testing\main.py", …
Run Code Online (Sandbox Code Playgroud)

python google-chrome selenium-chromedriver selenium-webdriver undetected-chromedriver

3
推荐指数
1
解决办法
8361
查看次数