当前位置:网站首页>Selenium is detected as a crawler. How to shield and bypass it
Selenium is detected as a crawler. How to shield and bypass it
2022-07-24 20:23:00 【Zeze said test】
Thank you for your reading and company , I put the automatic test content that I usually use more into a small volume of the system , You can directly click the text below to read , I hope to provide a little help for those who are destined .
Selenium Operation is blocked
Use selenium When automating web pages , There is a certain probability that it will be recognized by the target website , Once detected , The target website will block the web page operations made by the client .
For example, the landing pages of Taobao and public comments , When opening the browser manually , When you enter a user name and password , Can normally enter the home page , But if it's through selenium open , It will directly prompt that the verification fails , Click the box to try again .

This paper introduces a method , There is no need to modify browser properties , There's no need to inject JavaScript Script , It can also easily bypass website detection .
Selenium Why was it detected
Every time a browser visits a website , Will bring specific fingerprint features , The website will parse these features , To determine whether this visit is an automated program .
One of the most well-known features is window.navigator.webdriver, This feature directly indicates that this browser is webdriver Program . When a browser passes selenium After starting , Enter this property in the developer tool , You'll find it marked true, The browser opened manually is false.

actually , The browser was detected as webdriver This is not the only feature of the program , It means , Even if you modify the properties , It may not be able to bypass the detection of the website .
We can go through sannysoft To detect browser fingerprints , If the browser is through selenium When the automation program opens , After visiting this website, many features will expose these fingerprints , The values of these features are different from those after manual opening , So it can be easily detected by others .


Some people also try not to selenium, Switch to puppeter and playwright Such automation tools , But the ending is the same .
Selenium Methods to avoid being detected
The browser starts with a fingerprint , If an automated program is used, it has been marked when it is started , Then why not start it manually , And then use Selenium Connect to the browser that has been started ?
What should I do to open the browser manually to make Selenium How about the connection? ?Selenium How to connect to the browser opened manually ?
I am here Selenium Connect to an existing browser 1 This article details the steps required , Sum up :
1、 Add the following parameters when opening the browser :
--remote-debugging-port=9222 --user-data-dir="C:\selenium\ChromeProfile"
2、selenium Set browser options in , Through the... Set above 9222 Port connection browser :
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=chrome_options)
adopt subprocess Run the browser
Of course , To do automated programs, you usually don't click the icon manually to open the browser , We can start the browser from the command line , And then use selenium Connect .
import subprocess
cmd = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ' \
'--remote-debugging-port=9222 ' \
'--user-data-dir="C:\selenium\ChromeProfile"'
subprocess.run(cmd)
边栏推荐
- Alibaba Sentinel 基操
- Wechat applet -that.setdata ({}) set complex field data
- 872. Maximum common divisor
- Work notes - some problems encountered when using jest
- 英文翻译中文常见脏话
- The difference between delete, truncate and drop in MySQL
- Methods of using tyrosine modified peptide nucleic acid PNA | Tyr PNA | BZ Tyr PNA | 99Tcm survivinmrna antisense peptide nucleic acid
- ATL container - catlmap, crbmap
- Understand the domestic open source Magnolia license series agreement in simple terms
- Leetcode 206 reverse linked list, 3 longest substring without repeated characters, 912 sorted array (fast row), the kth largest element in 215 array, 53 largest subarray and 152 product largest subarr
猜你喜欢

Azide labeled PNA peptide nucleic acid | methylene blue labeled PNA peptide nucleic acid | tyrosine modified PNA | Tyr PNA Qiyue Bio

Elastomer simulation (elasticity)

Home Assistant中接入博联WiFi智能遥控
![[training Day8] tent [mathematics] [DP]](/img/d3/42869ed5bb7c9148d9fa7367a9af02.png)
[training Day8] tent [mathematics] [DP]

Setting up a dual machine debugging environment for drive development (vs2017)

API data interface of A-share transaction data

Do you want to enroll in a training class or study by yourself?

Apache atlas version 2.2 installation

Bypass using the upper limit of the maximum number of regular backtracking
![[training Day6] game [mathematics]](/img/b2/09c752d789eead9a6b60f4b4b1d5d4.png)
[training Day6] game [mathematics]
随机推荐
Login Huawei device in SSH mode
Lunch break train & problem thinking: on multidimensional array statistics of the number of elements
From code farmer to great musician, you only need these music processing tools
Alibaba sentinel basic operation
Ask a question: is there an error msg = ora-04036: instance usage when using CDC to monitor oracle
Near infrared dye cy7.5 labeling PNA polypeptide experimental steps cy7.5-pna|188re labeling anti gene peptide nucleic acid (agpna)
Wechat stores build order pages and automatically grab tickets
(posted) differences and connections between beanfactory and factorybean
Redis common configuration description
Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
《自尊的6大支柱》自尊来源于自身的感受
English grammar_ Demonstrative pronoun this / these / that / those
What is IDE (integrated development environment)
Conversion between VC string and timestamp
Introduction and advanced tutorial of Albert duilib
Unit DLU of resource editor
Istio二之流量劫持过程
Substr and substring function usage in SQL
Mysql8 doesn't seem to support MyISAM partition tables. Does polardb-x support MyISAM partition tables?
从码农转型大音乐家,你只差这些音乐处理工具