<> Verification Code

<>1, What is the verification code :

Refers to a kind of randomly generated information ( number , letter , chinese characters , picture , problem in arithmetic ) In order to prevent malicious request behavior , Increase application security

Registration or login is also required in the automation process , So we need to process the verification

<>2, Verification code processing method :

Remove the verification code

Operated by development , Used in test environment

This is the simplest way , For developers , Just comment out the relevant code of the verification code , If it is in the test environment , This will save the testers a lot of trouble , If the automated script is to run in a formal environment , This brings certain risks to the system .

Set universal verification code

Operated by development , Generally, it is only used in the test environment

Verification code recognition technology

Due to the high technical difficulty , Recognition rate is difficult to achieve 100%, It is generally not recommended to use records COOKIE Through record cookie To skip the login operation

Can pass add_cookie() Method to write the user name and password to the browser cookie, When you visit the website again, the server reads the browser directly Cookie Sign in

<>Cookie

1,Cookie principle

Cookie By Web Server generated , And a small text file saved on the user's browser , It can contain user related information

Cookie data format : Key value pair composition (python Dictionary in )

Cookie produce :

Client request server , If the server needs to record the user status , Just issue one to the client browser Cookie data

Cookie use :

When the browser requests the website again , The browser combines the requested data with Cookie Submit the data to the server together , Server check Cookie, To identify user status

2,Selenium operation cookie

driver.get_cookie(name) Get the cookie information , A dictionary is returned

driver.get_cookies() Get all cookie Information for , A list is returned

driver.add_cookie(dict_cookie) Add to browser driver cookie,dict_cookie It's a dictionary

Take Baidu as an example

BDUSS It is the only identity certificate after logging into Baidu (*.baidu.com), Get BDUSS It's equivalent to taking control of the account , Pass Post Bar , know , Encyclopedias , library , space , Baidu cloud and other major Baidu products .

Sign in baidu, Crawl after successful login (BDUSS)

use add_cookie() method , add to () Keys and values

Call refresh method driver.refresh()

How to get BDUSS Value of ?( Packet capturing implementation )

adopt fiddler After tool grabbing , obtain BDUSS

If the bag capturing tool is inconvenient , You can search through the browser cookie information

click chrome Browser settings

Enter in the settings search cookie

View all cookie And website data

Search Baidu domain name :baidu.com

obtain BDUSS

code implementation

After refresh , Result display

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?