参数 | 说明 | 示例 |
---|---|---|
-A | 设置user-agent | curl -A “Chrome” www.baidu.com |
-X | 使用指定方法请求 | curl -X POST http://httpbin.org/post |
-I | 只返回请求的头信息 | curl -I http://www.baidu.com |
-d | 以POST方法请求url,并发送相应的参数 | curl -d test=123 http://httpbin.org/post 多个参数 -d a=1 -d b=2 -d c=3 -d “a=1&b=2&c=3” @/tmp/post.data |
-O | 以远程文件名进行下载存储 | curl -O http://httpbin.org/images/jpeg |
-o | 自定义文件名进行下载存储 | curl -o dog.jpeg http://httpbin.org/images/jpeg |
-L | 跟随重定向请求 | curl -L https://baidu.com |
-H | 设置头信息 | curl -o dog.webp -H “accept:image/webp” http://httpbin.org/image |
-k | 可以发起不安全的SSL请求 | curl -k https://www.12306.cn |
-b | 设置cookies | curl -b a=test http://httpbin.org/cookies |
-s | 不显示其他无关信息 | alias myip=“curl -s http://httpbin.org/get|grep -E origin’|cut -d '”’ -f4" |
自定义一个命令,查看自己本地的外网ip
alias myip="curl http://httpbin.org/get|grep -E 'origin'|cut -d '\"' -f4"