Guyungy / damaihelper

支持大麦网,淘票票、缤玩岛等多个平台,演唱会演出抢票脚本
GNU Affero General Public License v3.0
974 stars 140 forks source link

报错 报错 WebDriver.__init__() got an unexpected keyword argument 'executable_path' #8

Open zhs981123 opened 7 months ago

zhs981123 commented 7 months ago

报错 WebDriver.init() got an unexpected keyword argument 'executable_path'

zhs981123 commented 7 months ago

配置文件中的driver_path路径也改了

Almbki commented 7 months ago

看看你的main.py中的enter_concert函数和config.json?

zhs981123 commented 7 months ago

``

看看你的main.py中的enter_concert函数和config.json?

{ "date": [ 14 ], "sess": [ 1, 2 ], "price": [ 1, 2, 3, 4, 5, 6 ], "real_name": [ 1 ], "nick_name": "", "ticket_num": 1, "viewer_person": [ 2 ], "driver_path": "E:\\damaihelper-main\\chromedriver.exe", "damai_url": "https://www.damai.cn/", "target_url": "https://m.damai.cn/damai/detail/item.html?itemId=714001339730", "comment": { "title": "comment 下的所有内容为自定义注释,无实际含义", "date": "1", "sess": "场次序号,优先选中的场次序号放在前,填写的场次序号若大于实际场次序号,则会选中实际场次序号最大的", "price": "票档序号,优先选中的票档序号放在前,填写的票档序号若大于实际票档序号,则会选中实际票档序号最大的", "real_name": "实名者序号,已经弃用", "nick_name": "用户昵称,已经弃用", "ticket_num": "购买票数,购买票数与观影人序号的数量务必一致", "viewer_person": "观影人序号(预先添加实名观影人),优先选中的序号放在前,填写的序号若大于实际序号,则会放弃选中", "driver_path": "驱动地址", "damai_url": "大麦首页地址,用于登录", "target_url": "购票的实际地址,需要使用手机端的地址,域名: https://m.damai.cn/ 开头", "queue": { "title": "列入待抢的链接地址", "zhoujielun_0403": "https://m.damai.cn/damai/detail/item.html?itemId=717235298514" } } }

zhs981123 commented 7 months ago

`def enter_concert(self): print(u'###打开浏览器,进入大麦网###') if not exists('cookies.pkl'): # 如果不存在cookie.pkl,就获取一下 print(self.driver_path) chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--headless") self.driver = webdriver.Chrome(executable_path=self.driver_path,options=chrome_options) self.get_cookie() print(u'###成功获取Cookie,重启浏览器###') self.driver.quit()

    options = webdriver.ChromeOptions()
    # 禁止图片、js、css加载
    prefs = {"profile.managed_default_content_settings.images": 2,
             "profile.managed_default_content_settings.javascript": 1,
             'permissions.default.stylesheet': 2}
    mobile_emulation = {"deviceName": "Nexus 6"}
    options.add_experimental_option("prefs", prefs)
    options.add_experimental_option("mobileEmulation", mobile_emulation)
    # 就是这一行告诉chrome去掉了webdriver痕迹,令navigator.webdriver=false,极其关键
    options.add_argument("--disable-blink-features=AutomationControlled")

    # 更换等待策略为不等待浏览器加载完全就进行下一步操作
    capa = DesiredCapabilities.CHROME
    # normal, eager, none
    capa["pageLoadStrategy"] = "eager"
    self.driver = webdriver.Chrome(
        executable_path=self.driver_path, options=options, desired_capabilities=capa)
    # 登录到具体抢购页面
    self.login()
    self.driver.refresh()
    # try:
    #     # 等待nickname出现
    #     locator = (By.XPATH, "/html/body/div[1]/div/div[3]/div[1]/a[2]/div")
    #     WebDriverWait(self.driver, 5, 0.3).until(EC.text_to_be_present_in_element(locator, self.nick_name))
    #     self.status = 1
    #     print(u"###登录成功###")
    #     self.time_start = time()
    # except:
    #     self.status = 0
    #     self.driver.quit()
    #     raise Exception(u"***错误:登录失败,请删除cookie后重试***")`
Thunderltx commented 7 months ago

解决了么

Almbki commented 7 months ago

检查一下selenium库的版本?我的是3.141.0的能运行,我看了一下,selenium 4.10.0的时候移除了executable_path参数,改成service参数了。所以改一下写法,或者重装低版本的selenium应该就可以了

Thunderltx commented 7 months ago

检查一下selenium库的版本?我的是3.141.0的能运行,我看了一下,selenium 4.10.0的时候移除了executable_path参数,改成service参数了。所以改一下写法,或者重装低版本的selenium应该就可以了

好了,可以了运行起来了。 但是又出现了【页面刷新出错】这个问题,我看别人也提到了这个问题#9

z2661214696 commented 6 months ago

检查一下selenium库的版本?我的是3.141.0的能运行,我看了一下,selenium 4.10.0的时候移除了executable_path参数,改成service参数了。所以改一下写法,或者重装低版本的selenium应该就可以了

您好 您这边谷歌版本是多少呀