curl 使用指南
curl 简介#
curl(CommandLine Uniform Resource Locator),命令行统一资源定位符。是一个利用 URL 规则在命令行下工作的文件传输工具。官方地址是:https://curl.haxx.se/
curl 支持多个操作系统,下载安装非常简单。安装完后,使用下面命令查看使用帮助:
D:\Users\xxx>curl -h
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail silently (no output at all) on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".
上面只是列出了部分使用帮助,查看全部使用帮助:curl --help all
常用 curl 实例#
1. 访问 Restfull 接口
curl -H "Content-Type: application/json" -H "referer: xxx" -X POST --data '{"userName":"Jessica1989","agencyCode":2}' http://xx.xx.xx.xx:8080/admin/xx
上面的命令以 Post 请求的方式,访问某接口,并在请求头中传了 referer 参数。
忽略https证书校验#
加上-k参数
curl -H "Content-Type: application/json" -H "referer: xxx" -X POST --data '{"key1":"value1"}' -k https://203.156.238.218:20357
参考#
作者:程序员自由之路
出处:https://www.cnblogs.com/54chensongxia/p/13847035.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?