1.Common Line Url Viewer
curl是一种命令行工具,作用是发出网络请求,然后得到和提取数据,显示在"标准输出"(stdout)上面。
2.-i参数可以显示http response的头信息,连同网页代码一起。
curl -i www.sina.com
3.发送表单信息有GET和POST两种方法。
(1)GET方法相对简单,只要把数据附在网址后面就行。
curl example.com/form.cgi?data=xxx
(2)POST方法必须把数据和网址分开,curl就要用到--data参数。
curl --data "data=xxx" example.com/one.php
4.假定文件上传的表单是下面这样:
<form method="POST" enctype='multipart/form-data' action="upload.php">
<input type=file name=upload>
<input type=submit name=press value="OK">
</form>
你可以用curl这样上传文件:
curl --form upload=@localfilename --form press=OK [URL]
5.使用--cookie参数,可以让curl发送cookie。
curl --cookie "name=xxx" www.example.com
6.如果需要在http request之中,自行增加一个头信息。--header参数就可以起到这个作用。
curl --header "xxx: xxxxxx" http://example.com
7.如果网域需要HTTP认证,这时curl需要用到--user参数。
curl --user name:password example.com