Explain web request and http protocol

Learn step by step and record the growth and footprint of the editor. Friends who want to learn python can refer to the blog I wrote before.

Web request:
When we visit Baidu in f, there will be a web request. After we enter a URL, the browser will also send a request to Baidu's server. Baidu's server will return Baidu's html. When we search for other content on Baidu, The content is sent to the Baidu browser in the form of parameters. After Baidu browser receives it, it will continue the internal search according to the parameters. Find the content according to the parameter and sort it. Write the content of the parameter into html. Then return with the parameter content uniformly. (Feature: can be seen in the source code)
(ctrl+f: webpage search shortcut)
server rendering (collecting data and html on the server and returning to the browser process)
Insert picture description here
client rendering: when you request web content , Just give you a html skeleton, then the browser will request the server data, and then the server will give the data. The client splices the skeleton and data together. (Feature: you can't see it in the source code of the page, you need to use the browser capture tool to find the data: right-click to check or F12)
Insert picture description here
http protocol: (hypertext protocol: the content in html is hypertext)
every time we visit www, When xxxxxxx.com will automatically add http or https, it means that the url address follows the http protocol.
Protocol: The rules set up for communication between two computers.

```python
'''
请求:
    请求行——请求方式(get,put,post等),请求url地址,协议
    请求头——服务器里使用的附加信息(放反爬内容)
    请求体——一般放请求参数
    
响应:
    状态行——协议,状态码(200,5000,302,401,404,403等等)
    响应头——放置客户端需要的一些附加信息
    响应体——服务器返回的真正客户端的要用的内容(HTML,json)等
'''

1, request method, 2, status code
Insert picture description here

'''
请求头:
1,User-Agent:请求载体的身份标识(用什么浏览器发送的请求)
2,Referer:防盗链(判别请求从哪里来,用来反爬)
3,cookie:本地字符串数据信息(用来用户登录,反爬的token)

响应头:
1,cookie:
2,各种各样的字符串(一般都是token字样,防止各种攻击和反爬)
'''

Common request sending (get, post)
get: display submission (usually used to view)
post: implicit submission (usually used to modify, add, upload server content)

Guess you like

Origin blog.csdn.net/weixin_47514459/article/details/114445855