首页 论坛 python的selenium4去除部分selenium特征
帖子详情

driver_path = r’E:\chrome-win64\chromedriver.exe’
options = Options()

# Configure options to disable automation detection
options.add_experimental_option(‘excludeSwitches’, [‘enable-automation’])
options.add_experimental_option(‘useAutomationExtension’, False)

# Initialize the WebDriver with the specified path and options
driver = webdriver.Chrome(service=Service(driver_path), options=options)

# Execute the CDP command to hide automation detection
driver.execute_cdp_cmd(‘Page.addScriptToEvaluateOnNewDocument’, {
‘source’: ‘Object.defineProperty(navigator, “webdriver”, {get: () => undefined})’
})

# Navigate to the URL
driver.get(self.url)

# Wait for user input before closing the browser
input()

# Close the browser
driver.quit()

selenium4使用这个代码可以较好的去除selenium的部分特征

 

 

版权:言论仅代表个人观点,不代表官方立场。转载请注明出处:https://www.shteam.cn/forum/169.html

点击联系客服

在线时间:8:00-16:00

客服电话

400-688-1348

客服邮箱

shanhai@shserve.cn

扫描二维码

关注微信公众号

扫描二维码

手机访问本站