Last active
November 24, 2022 05:23
-
-
Save loveklmn/d072440e28167b2c48310f9cb66b65b9 to your computer and use it in GitHub Desktop.
avoid selenium detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
options = webdriver.ChromeOptions() | |
options.add_argument("start-maximized") | |
options.add_experimental_option("excludeSwitches", ["enable-automation"]) | |
options.add_experimental_option("useAutomationExtension", False) | |
driver = webdriver.Chrome(options=options) | |
with open('./stealth.min.js') as f: # https://raw.githubusercontent.com/requireCool/stealth.min.js/main/stealth.min.js | |
js = f.read() | |
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": js }) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment