python+selenium 被检测到,难以解决?

python+selenium  被检测到,难以解决?

python+selenium  被检测到,难以解决?
运行代码的时候,出现这个滑块,一滑动就显示error
但是,我已经把window.navigator.webdriver修改为
undefined
最后还是不行,求指教。

讨论数量: 2
Jason990420

我用下面的代码,没有滑块,直接就登录了

注-PySimpleGUI只是用来作GUI

from selenium import webdriver
from selenium.webdriver import ChromeOptions
import PySimpleGUI as sg

option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
option.add_experimental_option('useAutomationExtension', False)
browser = webdriver.Chrome('D:/Python/Project/chromedriver', options=option)
browser.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {
   'source': 'Object.defineProperty(navigator, "webdriver", {get: () => undefined})'
})
browser.get('https://www.taobao.com')

layout = [[sg.Button('Quit')]]
window = sg.Window("Title", layout, finalize=True)

while True:
    event, values = window.read()
    if event in (sg.WINDOW_CLOSED, 'Quit'):
        break
    print(event, values)

browser.close()
browser.quit()
window.close()
3年前 评论
Mr_luoYu (楼主) 3年前
Mr_luoYu (楼主) 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!