HTTP 请求格式
1 动词 路径 协议/版本
2 Key1: value1
2 Key2: value2
2 Key3: value3
2 Content-Type: application/x-www-form-urlencoded
2 Host: www.baidu.com
2 User-Agent: curl/7.54.0
3
4 要上传的数据
使用 Chrome 查看 http 请求头
- 打开 Chrome
- 打开 inspector
- 输入网址
- 点击 network
- 找对对应的请求
- 点击 view source
HTTP 响应格式
1 协议/版本号 状态码 状态解释
2 Key1: value1
2 Key2: value2
2 Content-Length: 17931
2 Content-Type: text/html
3
4 要下载的内容
curl 的使用
- GET 请求
curl -s -v -H -- "https://www.baidu.com"
请求内容为:
- POST 请求
curl -X POST -s -v -H -- "https://www.baidu.com"
请求内容为:
curl -X POST -d "123456789" -s -v -H -- "https://www.baidu.com"
curl参数含义可以访问 curl 来查看。