curl常用命令备忘

时间:2023-03-09 00:19:30
curl常用命令备忘
#####(输出请求头信息) curl -I
xxx-Pro:test xxx$ curl -I https://www.baidu.com/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy- revalidate, no-transform
Connection: Keep-Alive
Content-Length: 277
Content-Type: text/html
Date: Wed, 24 Apr 2019 09:37:25 GMT
Etag: "575e1f6d-115"
Last-Modified: Mon, 13 Jun 2016 02:50:21 GMT
Pragma: no-cache
Server: bfe/1.0.8.18 #####(需要post的data数据) curl -d
curl -d 'name=xxx&passwd=yyy' www.baidu.com #####(要输出的文件地址 输出cookie信息) curl -c
curl -c cookie -d 'email=xxx&password=yyy' http://api.xxx.cn:8115/api/user/login
{"errcode":0,"errmsg":"logout success...","data": {"username":"xxx","role":"member","uid": 1100,"email":"xxx","add_time":1542010178 #####(携带cookie进行请求) curl -b cookie www.baidu.com #####(自定义header ) curl -H 'User-Agent: Custom-User-Agent' #####(把输出写到该文件) curl -o curl -o ./baidu.html http://www.baidu.com
ls
baidu.html #####(把输出写到该文件中,保留远程文件的文件名) curl -O https://www.baidu.com/img/baidu_resultlogo@2.png #####(上传文件) curl -T xxx.txt -u 用户名:密码 ftp://www.xxxx.com/txt/