# 绕过反爬虫网站检测 Python + selenium 4.0 **Published by:** [RushB](https://paragraph.com/@rushb-2/) **Published on:** 2022-10-19 **URL:** https://paragraph.com/@rushb-2/python-selenium-4-0 ## Content from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium import webdriver from time import sleep, time # https://bot.sannysoft.com/ 以下代码通过该网站的反爬虫检测 # 通过反爬虫检测需要重要的文件 stealth.min.js 需要及时更新 # https://github.com/requireCool/stealth.min.js option = webdriver.ChromeOptions() option.add_experimental_option('excludeSwitches', ['enable-automation']) driver = webdriver.Chrome(options=option) driver.maximize_window() with open('./stealth.min.js') as f: js = f.read() driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", { "source": js }) driver.get("https://bot.sannysoft.com/") Subscribe ## Publication Information - [RushB](https://paragraph.com/@rushb-2/): Publication homepage - [All Posts](https://paragraph.com/@rushb-2/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@rushb-2): Subscribe to updates