curl 基本使用
- 最简单的直接请求页面
curl "https://www.baidu.com"
- 请求保存页面
curl "https://www.baidu.com" > /path/name.html
-o
保存页面curl -o /path/name.html "https://www.baidu.com"
--progress
显示进度条-s
加入这个就不会出现进度条,安静模式-A
参数用来指定 USER-AGENGTcurl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17" http://localhost/learing-curl/show-server-info.php
-e
指定 referer 来源网址curl -e "https://www.google.com/" http://localhost/learing-curl/show-server-info.php
-d
post 请求curl -d "name=1" "http://localhost:6666/post"
-G
轻质指定表单以 GET 方法提交-I
只展示 Headercurl -I http://www.baidu.com
-D
保存 Header 到文件里curl -D header.txt http://www.alibaba.com
-L
跟随重定向过去curl -L http:localhost:6666/red
-F
提交文件curl -F upload_file=@test.data url
-c
保存 cookiecurl -c cookie.txt https://www.baidu.com
-b
带 coolie 访问curl -b "name=data" url
curl -b cookie.txt url
-H
设置请求头-m
设置最大传输时间 seconds-u
设置服务器用户名和密码curl -u name:password url
1 | curl 'https://oapi.dingtalk.com/robot/send?access_token=6fb5741248b308d1eb616f993fddf0fb3459f42cb6b4eb86078e33042b5bc4e0' \ |
1 | curl 'http://www.ferryvip.com/v1/me/webhook' \ |