阅读量:0
curl -X GET "https://api.example.com/data?param1=value1¶m2=value2",这个命令使用curl发送一个GET请求到指定的URL,并附带查询参数。

Curl是一个强大的命令行工具,用于与服务器进行通信,它支持多种协议,如HTTP、HTTPS、FTP等,下面是一个使用Curl发送GET请求的示例:
1、基本GET请求
curl http://example.com
2、添加请求头
curl -H "Content-Type: application/json" http://example.com
3、发送带有参数的GET请求
curl -d "param1=value1¶m2=value2" http://example.com
4、发送带有请求头的GET请求
curl -H "Content-Type: application/json" -d "param1=value1¶m2=value2" http://example.com
5、发送带有Basic认证的GET请求
curl -u username:password http://example.com
6、发送带有自定义User-Agent的GET请求
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" http://example.com
7、发送带有Referer的GET请求
curl -e "http://referer.com" http://example.com

8、发送带有Cookie的GET请求
curl -b "name=value; name2=value2" http://example.com
9、发送带有多个Cookie的GET请求
curl -b "name=value; name2=value2" -b "name3=value3; name4=value4" http://example.com
10、发送带有多个请求头的GET请求
curl -H "Content-Type: application/json" -H "Authorization: Bearer token" http://example.com
11、发送带有多个请求头的GET请求(使用@符号从文件中读取)
curl -H @headers.txt http://example.com
在这个示例中,headers.txt
文件包含以下内容:
Content-Type: application/json Authorization: Bearer token
