The selenium framework operates the stealth.min.js file to hide browser fingerprinting features

Article directory

What is browser fingerprinting?

Browser fingerprints are various pieces of information about your browser that help websites identify us when we visit other websites, even in anonymous mode.

The uniqueness of fingerprints on the human hand is because each fingerprint has a unique pattern, which is formed by bumpy skin and has unique characteristics.

Browser fingerprints are similar to fingerprints on human fingers, and both have unique characteristics. The website obtains the identification information of the browser and performs some calculations to obtain a value, then this value is the browser fingerprint.

Manually open the browser fingerprint situation

Under normal circumstances, manually open the browser and enter the URL [] :

[]Open browser in [selenium interfaceless mode]

Selenium operates the browser, there are dozens of features that can be detected by the website, and it is easy to identify you as a crawler.

Open the browser in selenium interfaceless mode:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(chrome_options=chrome_options)


# Take a screenshot of the current page 
driver.save_screenshot( '1.png' )


Generate image:

Obviously, the website has been found to be a crawler!

How to hide browser fingerprints

The key to solving the browser fingerprint feature is actually a stealth.min.jsfile . Executing this js file through Python can hide the browser fingerprint

stealth.min.jsFile download address: pay attention to the public number at the end of the article, reply:Hide browser fingerprint

Add request header + execute stealth.min.jsfile to hide browser fingerprint:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument( '--disable-gpu' )
 # Add request header to disguise browser
    'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36')
driver = webdriver.Chrome(chrome_options=chrome_options)

with open('stealth.min.js') as f:
    js =

driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": js


operation result:

By executing stealth.min.jsto hide the browser fingerprint, it is the same as normal access!

Leave a Comment

Your email address will not be published. Required fields are marked *