木良450 2021-11-27 22:12 采纳率: 75%
浏览 1477
已结题

TypeError: __init__() got an unexpected keyword argument 'options' 这是什么情况,我该怎么该

import time

from selenium import webdriver

1.创建选项对象

chrome_options = webdriver.ChromeOptions()

2.添加参数,进行隐藏

chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])

3.谷歌浏览器对象

chrome_obj = webdriver.Chrome(options=chrome_options)

chrome_obj.get("https://www.baidu.com/")

time.sleep(3)

chrome_obj.quit()

---------------------------------------------

这是报错信息

Traceback (most recent call last):
File "E:/11期爬虫班/爬虫课程/第七周/19-selenium使用/19.1selenium反检测.py", line 10, in
chrome_obj = webdriver.Chrome(options=chrome_options)
TypeError: init() got an unexpected keyword argument 'options'

  • 写回答

1条回答 默认 最新

  • CSDN专家-link 2021-11-27 22:24
    关注

    试试chrome_options = options

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月5日
  • 已采纳回答 11月27日
  • 创建了问题 11月27日