当前位置:网站首页>Selenium builds cookies pool to bypass authentication and anti crawl login
Selenium builds cookies pool to bypass authentication and anti crawl login
2022-06-26 08:52:00 【Feng Dashao】
The previous blog introduced , Today's Internet developers are trying to reduce the impact of various crawlers on servers , Various anti climbing mechanisms have been adopted . Recently someone raised a question , Algorithm cracking without verification code , How to complete Selenium Fully automatic login ? In fact, since there is an anti climbing mechanism , There must be every way to crack it , It's just that the complexity of each is different . Today I will introduce a more direct method , By building Cookies Pool to bypass the verification step .
Cookie It is a short text file stored by the browser on the user's computer . The encrypted user information is stored in this file (User ID, Password), Expiration time (Expired Date/Time) wait .
because Cookie There is an expiration date , chart 1,t because Cookies involve User/Password, Here is the code of the occlusion part . When it fails , You need to log in again , Generate a new Cookie. Simple understanding , It is like a Hong Kong and Macao pass , After the validity of the visa , You have to sign again before you can use .
Therefore, we must first complete a manual normal login , Automatic system generation Cookies, And then through response.cookies() Method to get directly , Of course , If you are not familiar with fast extraction through code , You can also manually copy and paste , More time-consuming .
By getting Cookies after , First add an empty lst, Then put multiple Cookies To form an independent dict, Add to this empty by looping lst in , Formed a Cookies pool , chart 2
Quickly set up Cookies Behind the pool , When we open the corresponding URL after , You can let the browser automatically add one by one through a loop Cookie, When I'm done , Refresh the browser , Code in :
Something to pay attention to ,add_cookie() Methodical params Must contain “Name” and " Value", Otherwise, an error will be reported . So in creating an independent Cookie, The format must be {‘name’:‘xxx’, ‘value’:‘xxxx’}, So it can be interpreted as name Equivalent to Cookie Of Key,value Equivalent to value ( Key_Value Key value pair ) .
Last , Create a class , hold Selenium Set the properties of ,
hold Cookies pool , All the added methods are encapsulated in a custom function , Run it , You can achieve the effect of automatic login . A final reminder , dependent Cookies Don't give it to others , The code program must be encrypted and kept well , Because it's related User/Password There is a risk of being decompiled and stolen , Here we will not introduce how to compile Cookie Restore real information .
for i in cookies:
browser.add_cookie(i)
browser.refresh()
chart 1

chart 2

边栏推荐
- Using transformers of hugging face to realize multi label text classification
- Remote centralized control of distributed sensor signals using wireless technology
- (2) Buzzer
- 在同花顺开户证券安全吗,
- Realizing sequence annotation with transformers
- Trimming_ nanyangjx
- Speckle denoising method for ultrasonic image
- [已解决]setOnNavigationItemSelectedListener()被弃用
- STM32 project design: an e-reader making tutorial based on stm32f4
- Using transformers of hugging face to realize named entity recognition
猜你喜欢

Object extraction_ nanyangjx

Trimming_ nanyangjx

Transformers loading Roberta to implement sequence annotation task

Nebula diagram_ Object detection and measurement_ nanyangjx

STM32 porting mpu6050/9250 DMP official library (motion_driver_6.12) modifying and porting DMP simple tutorial

Leetcode22 summary of types of questions brushing in 2002 (XII) and collection search

Learn signal integrity from zero (SIPI) - (1)

Euler function: find the number of numbers less than or equal to N and coprime with n

爬虫 对 Get/Post 请求时遇到编码问题的解决方案

MPC learning notes (I): push MPC formula manually
随机推荐
MPC learning notes (I): push MPC formula manually
Google Chrome collection
Torch model to tensorflow
STM32 project design: an e-reader making tutorial based on stm32f4
Compiling owncloud client on win10
Application of wireless charging receiving chip xs016 coffee mixing cup
Realizing sequence annotation with transformers
Golang JSON unsupported value: Nan processing
Jupyter的安装
Detailed explanation of SOC multi-core startup process
(3) Dynamic digital tube
Whale conference one-stop intelligent conference system helps organizers realize digital conference management
HEVC学习之码流分析
Euler function: find the number of numbers less than or equal to N and coprime with n
OpenGL display mat image
Assembly led on
STM32 project design: smart home system design based on stm32
Record the problem yaml file contains Chinese message 'GBK' error
Summary of common instructions for arm assembly
Addition of attention function in yolov5