当前位置:网站首页>curl 命令妙用
curl 命令妙用
2022-07-04 15:43:00 【Wu_Candy】
curl 介绍:
curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP,FTPS,HTTP,HTTPS,GOPHER,TELNET,DICT,FILE及LDAP等协议。curl支持HTTPS认证,并且支持HTTP的POST,PUT等方法,FTP上传,kerberos认证,HTTP上传,代理服务器,cookies,用户名/密码认证,通过http代理服务器上传文件到FTP服务器等等,功能十分强大。本文主要分享一些常用的场景:
curl 常用参数:
-I 只显示请求头信息
-d HTTP POST方式传送数据,以json格式
-o 把输出写到该文件中
-s 静默模式。不输出任何东西
-X 指定什么命令,如GET POST
-v 查看详情
-u 设置服务器的用户和密码
-H 要发送到服务端的自定义请求头
-w 完成后输出什么
-b 从文件中读取cookie信息
-F 上传文件
-# 显示进度条
No 1:curl 命令发送get请求
示例:curl -X GET http://www.xxx.com/search?data=123
No 2:curl 命令发送get请求后统计各阶段耗时
curl -o /dev/null -s -w "time_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" www.xxx.com
No 3:curl 命令发送post请求
curl www.xxx.com/api/openservice/query/queryProperty -H "Content-Type:application/json" -X POST -d '{"baseCondition": {"propertyId": 1, "dateRange": {"fromDate": "2019-07-04", "toDate": "2019-07-05"}, "adults": 1,"children": 0, "rooms": 1, "channelId": 2, "sellCategories": ["PUBLIC", "NEGOTIATE"]},"extensionCondition": {"rateIds": [], "unableFlag":"False", "currency": "CNY"}, "context": {}}'
No 4:curl 命令发送post请求后统计各阶段耗时
curl -o /dev/null -s -w "time_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" www.xxx.com/api/openservice/query/queryProperty -H "Content-Type:application/json" -X POST -d '{"baseCondition": {"propertyId": 1, "dateRange": {"fromDate": "2019-07-04", "toDate": "2019-07-05"}, "adults": 1,"children": 0, "rooms": 1, "channelId": 2, "sellCategories": ["PUBLIC", "NEGOTIATE"]},"extensionCondition": {"rateIds": [], "unableFlag":"False", "currency": "CNY"}, "context": {}}'
No 5:curl 命令保存文件到本地
curl -o file.html http://www.xxx.com/index.html
No 6:curl 命令登录服务
curl -u name:passwd http://www.xxx.com
No 7:curl 命令构造一个请求头
curl -H "Content-Type:application/json" http://www.xxx.com
No 8:curl 命令从文件中读取cookie 信息
curl -b "cookie.txt" http://www.xxx.com
No 9:curl 命令上传文件
curl -b "cookie.txt" -F "[email protected]/temp/a.txt" http://www.xxx.com/api/upload -v
No 10:curl 命令下载文件并显示下载进度
curl -# -o abc.jpg http://www.xxx.com/abc.JPG
No 11:curl 命令清除es 里面的数据
curl -XDELETE http://10.8.102.102:9200/entity-beta-ars6_ars-reservation -uadmin:admin #清理ES
边栏推荐
- 智慧物流园区供应链管理系统解决方案:数智化供应链赋能物流运输行业供应链新模式
- Perfectly integrated into win11 style, Microsoft's new onedrive client is the first to see
- Great Wall Securities security does not open a securities account
- The 18th IET AC / DC transmission International Conference (acdc2022) was successfully held online
- 【HCIA持续更新】网络管理与运维
- S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
- OPPO小布推出预训练大模型OBERT,晋升KgCLUE榜首
- Implementation of super large-scale warehouse clusters in large commercial banks
- 【模板】【luogu P4630】Duathlon 铁人两项(圆方树)
- Pytorch deep learning quick start tutorial
猜你喜欢

The winning rate against people is 84%, and deepmind AI has reached the level of human experts in army chess for the first time

Go micro tutorial - Chapter 2 go micro V3 using gin and etcd

开发者,MySQL专栏完更,助你轻松从安装到入门进阶

智捷云——元宇宙综合解决方案服务商

整理混乱的头文件,我用include what you use

第十八届IET交直流输电国际会议(ACDC2022)于线上成功举办

"Cannot initialize Photoshop because the temporary storage disk is full" graphic solution

With an annual income of more than 8 million, he has five full-time jobs. He still has time to play games

La 18e Conférence internationale de l'IET sur le transport d'électricité en courant alternatif et en courant continu (acdc2022) s'est tenue avec succès en ligne.

Implementation of super large-scale warehouse clusters in large commercial banks
随机推荐
2022年国内云管平台厂商哪家好?为什么?
智慧物流园区供应链管理系统解决方案:数智化供应链赋能物流运输行业供应链新模式
PingCode 性能测试之负载测试实践
Go development: how to use go singleton mode to ensure the security of high concurrency of streaming media?
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
R语言plotly可视化:plotly可视化多分类变量小提琴图(multiple variable violin plot in R with plotly)
Is it safe for Great Wall Securities to open an account? How to open a securities account
7 RSA密码体制
The winning rate against people is 84%, and deepmind AI has reached the level of human experts in army chess for the first time
Display opencv drawn pictures on MFC picture control control
Smart Logistics Park supply chain management system solution: digital intelligent supply chain enables a new supply chain model for the logistics transportation industry
Unity interview questions (continuously updated)
昆明三环闭合工程将经过这些地方,有在你家附近的吗?
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue
【模板】【luogu P4630】Duathlon 铁人两项(圆方树)
KS007基于JSP实现人个人博客系统
建筑建材行业经销商协同系统解决方案:赋能企业构建核心竞争力
网页游戏引擎
[acwing] 58 weeks 4490 dyeing