本文共 591 字,大约阅读时间需要 1 分钟。
curl用来请求 Web 服务器。顾名思义就是客户端(client)的 URL 工具的意思。
1.不带有任何参数时,curl 就是发出 GET 请求。
curl http://www.baidu.com |
-A (--user-agent)参数指定客户端的用户代理标头,即User-Agent
curl 的默认用户代理字符串是curl/[version]
。
-e (--referer)用来设置 HTTP 的标头Referer
,表示请求的来源。
-i 打印出服务器回应的 HTTP 标头
-I 向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来。
-o 将服务器的回应保存成文件,等同于wget
命令。
curl -o example.html https://www.example.com
上面命令将www.example.com
保存成example.html
。
-O 将服务器回应保存成文件,并将 URL 的最后部分当作文件名。
-v 输出通信的整个过程,用于调试。
-x 指定 HTTP 请求的代理。
curl -x james:cats@myproxy.com:8080 https://www.example.com
-X 指定 HTTP 请求的方法
$ curl -X POST https://www.example.com
未完待续.......
转载地址:http://neiqi.baihongyu.com/