curl用法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
GET请求:
curl https://www.xxx.com

POST请求:
curl -d key=value https://www.xxx.com

填写表单:
curl -F key1=value1 -F key2=value2 https://www.xxx.com/xxx.cgi

显示信息:
curl -i https://www.xxx.com

指定USER-AGENT
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" https://www.xxx.com
注:若留空则移除User-Agent标头

跟随重定向:
curl -L https://www.xxx.com
注:curl默认不跟随重定向

发送cookie:
curl -b "foo=bar" https://www.xxx.com

url编码:
curl --data-urlencode "xxxxxxx" https://www.xxx.com
注:该方式与-d相近,区别在于是否编码

保存网页(与wget相似):
curl -o xxx.html https://www.xxx.com

用户认证:
curl -u "user:passwd" https://www.xxx.com/login

输出通信过程:
curl -v https://www.xxx.com

输出二进制数据:
curl --trace - https://www.xxx.com
注:可配合-o导出

quote
https://www.jianshu.com/p/fc0eb6c60816
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html

评论