curl www.sina.com
<html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html>如果要把这个网页保存下来,可以使用-o参数,这就相当于使用wget命令了。
curl -o [文件名] www.sina.com
curl -L www.sina.com键入上面的命令,结果就自动跳转为www.sina.com.cn并显示源码。
curl -I www.sina.com curl -i www.sina.com
HTTP/1.1 301 Moved Permanently Server: nginx Date: Wed, 17 Jun 2015 13:54:42 GMT Content-Type: text/html Location: http://www.sina.com.cn/ Expires: Wed, 17 Jun 2015 13:56:42 GMT Cache-Control: max-age=120 Age: 102 Content-Length: 178 X-Cache: HIT from xd33-96.sina.com.cn <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html>
curl -v www.sina.com查看更详细的通信过程:
curl --trace output.txt www.sina.com或者
curl --trace-ascii output.txt www.sina.com运行后,请打开output.txt文件查看。
curl example.com/form.cgi?data=xxx发送表单信息(POST):
curl --data "data=xxx" example.com/form.cgi发送表单信息,数据编码(POST):
curl --data-urlencode "date=April 1" example.com/form.cgi
curl -X POST www.example.com curl -X DELETE www.example.com
curl --referer http://www.example.com http://www.example.com
curl --user-agent "[User Agent]" [URL]
curl --cookie "name=xxx" www.example.com
curl --header "Content-Type:application/json" http://example.com
curl --user name:password example.com
原文地址:http://blog.csdn.net/ligang2585116/article/details/46548617