Linux Curl常用命令
CURL是一个开源项目,基于网络协议,对指定URL进行网络传输。涉及是任何网络协议传输,但不涉及对具体数据的具体处理。
发送Get请求
响应内容返回至屏幕
1
2
3
curl curl https:
//
catonmat.net
响应内容保存至文件response.txt
1
2
3
curl -o response.txt https:
//
catonmat.net
发送POST请求
发送带表单数据的 POST 请求
1
2
3
4
5
6
7
curl -d
'login=emma'
-d
'password=123'
https:
//g
oogle.com/login
读取文件内容发送的 POST 请求
1
2
3
4
5
curl -d
'@data.txt'
https:
//g
oogle.com/login
携带Cookies
携带空Cookies
1
2
3
4
5
curl -b
'session='
https:
//g
oogle.com
携带Cookies
1
2
3
4
5
curl -b
'session=abcdef'
https:
//g
oogle.com
访问并写入Cookies到文件
1
2
3
curl -c cookies.txt https:
//
www.google.com
读取Cookies文件访问
1
2
3
4
5
6
curl -
b
cookies
.txt
https:
//www.google.com
跳过SSL检测
1
2
3
curl -k https:
//
www.example.com
跟随服务器重定向
1
2
3
4
5
curl -L -d
'tweet=hi'
https:
//
api.twitter.com/tweet
修改用户代理
将用户代理更改为 Chrome
1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl
-A 'Mozilla/
.
(Windows NT
.
; Win64; x64) AppleWebKit/
.
(KHTML, like Gecko) Chrome/
.
.
.
Safari/
.
' https://google.com
假装成谷歌机器人
1
2
3
4
5
curl -A
'Googlebot/2.1 (+http://www.google.com/bot.html)'
https:
//
washingtonpost.com
HTTP身份验证
1
2
3
4
5
6
curl https://
bo
b:12345
@google.
com
/login
限制Curl
限制为每秒 200 KB,一般用于模拟慢网速环境
1
2
3
4
curl --limit-rate
k https:
//g
oogle.com
限制为每秒 1 个字节
1
2
3
4
curl --limit-rate
https:
//g
oogle.com
输出通信过程
一般用于调试
1
2
3
curl -v https:
//
www.example.com
不输出错误和进度信息
如运行正常,会正常显示结果
1
2
3
curl -s https:
//
www.example.com
Linux Curl常用命令
https://zhouyinglin.top/2023/03/06/Linux Curl常用命令/