Interface address: http://www.testingedu.com.cn:8000/index.php/Home/user/index.html
Capture tool: fiddler
Interface testing tools: fiddler, postman, jmeter, requests
idea:pycharm+python3.9
foreword
Hope you get something after reading it. V: qing_an_an, official account:
fiddler
premise
What is the prerequisite for changing the avatar? Log in, of course. Go through the sessions, pause the packet capture, find the personal information on the web page, and then open fiddler to manually change the avatar. It can be seen that the replacement was successful. Why is this an interface for changing the avatar? In addition to success, you can also capture packets step by step! Once the key information is obtained, we use the tool to repeat the operation.
Step 1: Get the cookie
Select Cookie directly CTRL+C
Step 2: Add parameters
How to change the packet capture parameters, see below:
Step 3: Initiate a request
important point:
Why is one parameter enough? Because others can be regarded as no need to pass parameters. After adding pictures in step 2, a column of parameters will be added in Psrsed, which is a must.
postman
After fiddler, the parameters are all there, and the rest is just copying.
Step 1: Fill in the parameters
The url address can be taken directly from fiddler.
Step 2: Initiate a request
Notice:
The parameters of step 1 and step 2 are the same, here is just to tell you that the parameters are optional
jmeter
Step 1: Add Appliances
❝Test Plan >> Add >> >> Thread (User)
❞
❝Add Thread Group》》》Add》》》"Sampler》》》HTTP Request (Avatar Upload)
❞
❝Add thread group """Add"""Listener"""View result tree
❞
❝Add Thread Group》》》Add》》》Configuration Originals》》》HTTP Information Header Management
❞
"Just add the above four"
Step 2: Parameters of each appliance
The parameter here is the cookie. Refer to step 1 in fiddler and pay attention to the port number, because the project has already been specified. The parameters here are also optional. The important thing is this step, pay attention. Exactly the same as postman.
Step 3: Initiate a request
python
Step 1: Import package
import requests
If not, pip install requests
Step 2: Go back to postman
Pay attention to the three items circled in the picture, step by step from left to right.
Step 3: Back to pycharm
import requests
url = "http://www.testingedu.com.cn:8000/index.php/home/Uploadify/imageUp/savepath/head_pic/pictitle/banner/dir/images.html?"
payload={'filename': '2.jpg'}
files=[
('file',('2.jpg',open('E:/VUE_DEMO/src/2.jpg','rb'),'image/jpeg'))
]
headers = {
'Cookie': 'PHPSESSID=3dl8qf3crfk0mo9e6lu4td6gl6; is_distribut=0; is_mobile=0; uname=%25E7%25A7%258B%25E7%25A7%258B; user_id=8'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Just copy it in. The cookies and headers here are all parameters in postman. If you can't understand the code, it's okay to use the tool well. The code will be explained later.
Step 4: Run the code
Actual combat:
CSDN actual combat interface to change the avatar:
Step 1: Go through the process
First register an account and log in. We only change the avatar on the actual combat interface, no need to grab other packages!
Step 2: Open fiddler and enter csdn
Be sure to enter the personal data interface first, then start packet capture, and manually change the avatar once. Why can you quickly determine the interface, you can see the name, and the location of the avatar picture. Under normal circumstances, the upper part of the picture is enough, and you can check the parameters to confirm.
Step 3: Get started
Finally, the request is initiated. You can go to CSDN to see for yourself, the avatar is already under review. Don't forget to modify the filename parameter, which is the location of your picture.