如何在kali linux中使用undetected_chromedriver.v2
import undetected_chromedriver.v2 as uc
options = uc.ChromeOptions()
# setting profile
options.user_data_dir = "c:\\temp\\profile"
# another way to set profile is the below (which takes precedence if both variants are used
options.add_argument('--user-data-dir=c:\\temp\\profile2')
# just some options passing in to skip annoying popups
options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
bw = uc.Chrome(options=options, version_main=92)
发布于 2021-12-02 23:38:29
如果您使用的是selenium4,则使用时会出现以下错误:
TypeError: __init__() got an unexpected keyword argument 'service'
根据状态进行内联:
2021年7月:目前正忙于为未检测到的chromedriver实现selenium 4
但是,对于selenium4,您仍然可以使用,如下所示:
import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
options = uc.ChromeOptions()
options.add_argument("start-maximized")
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = uc.Chrome(service=s, options=options)
driver.get('https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/')
driver.save_screenshot('datadome_undetected_webddriver.png')
参考文献
您可以在以下位置找到几个相关的详细讨论:
https://stackoverflow.com/questions/70194755
复制相似问题