What is the use of simulating HTTP requests?
All we need to use the Internet now: Most of the features in the Software App app website are working through the HTTP protocol.
What is the HTTP protocol?
HTTP protocol, Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet.
Need to know more about HTTP please search by yourself, this article briefly talk about the HTTP request process
The request is sent by the client, the request is a piece of text (Request message), the server gets the parameters in the request, is processed by the backend, and then performs the corresponding function.
The service side returns a paragraph of text (the response message, there is no return information), the client gets the information in the message, make a corresponding display.
We use an app user registration as an example
When the user needs to register, fill in the completion of their mobile phone number (no request occurred at this time)
Click the Get Captcha button, at which point the client (APP) sends a request message to an address containing the phone number you filled in:
The request contains a phone parameter with the value of your phone number
Then the server receives your mobile phone number, executes the SMS Verification code function, and then sends the response message to the client:
The response message contains a number of parameters, the server to get these parameters, to make a corresponding display (such as display: Message sent successfully)
The above completes an HTTP interaction,
According to the above example, we can pass the analog request message, pass on someone's mobile number, send the request multiple times, realize the harassment of the mobile phone number owner (SMS Bomber function)
How do I simulate the request?
First we need to install the requests module
Installation commands
PIP Install requests
First analyze the request
The request method in the figure is post, so we need to use the Requests.post (url,headers,data) function, which requires three parameters, as shown in the picture
Fill
In a Python program
Import Requests # Import Module
Url= "http://bbs.zcbxw.com/mag/xxx/xx/..." #自行补全
headers={"Host": "bbs.zcbxw.com", "xxx": "xxx", "xx": "XX"} self-complement
Data= "phone= mobile phone number &country_code=86"
Requests.post (Url=url,headers=headers,data=data)
#将headers与url按照图中所示补全, the other code does not change, runs, completes a request
Teaches you how to simulate HTTP requests with Python (get,post)