curl

来源:互联网 发布:网络思想政治教育报告 编辑:程序博客网 时间:2024/06/07 06:33

1、开启gzip请求

curl -I http://www.sina.com.cn/ -H Accept-Encoding:gzip,defalte

2、监控网页的响应时间

curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "http://www.kklinux.com"-o 指定输出位置-s 不打印curl的错误信息-w 格式化输出

3、 监控站点可用性

curl -o /dev/null -s -w %{http_code} "http://www.kklinux.com"

4、读取网页

curl http://www.linuxidc.com GET模式    curl http://www.yahoo.com/login.cgi?user=nickwolfe&password=12345 POST模式    curl -d "user=nickwolfe&password=12345" http://www.yahoo.com/login.cgi

5、保存网页 【-o filename】

curl http://www.linuxidc.com > page.html curl -o page.html http://www.linuxidc.com 

6、使用的proxy服务器及其端口【-x】

 curl -x 123.45.67.891080 -o page.html http://www.linuxidc.com 

7、使用cookie来记录session信息 【-D】

curl -x 123.45.67.891080 -o page.html -D cookie0001.txt http://www.linuxidc.com  -D 是把http的response里面的cookie信息存到一个特别的文件中去,这样,当页面被存到page.html的同时,cookie信息也被存到了cookie0001.txt里面了

8、使用上次留下的cookie信息到新请求【-b filename】

curl -x 123.45.67.891080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.linuxidc.com 

9、模拟设置浏览器信息【-A】

curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -o page.html  http://www.yahoo.com 

10、盗链【-e 】
  另外一个服务器端常用的限制方法,就是检查http访问的referer。比如你先访问首页,再访问里面所指定的下载页,这第二次访问的referer地址就是第一次访问成功后的页面地
址。这样,服务器端只要发现对下载页面某次访问的referer地址不 是首页的地址,就可以断定那是个盗连了

curl  -e "mail.yahoo.com" -o page.html -D cookie0001.txt http://www.yahoo.com 骗对方的服务器,你是从mail.yahoo.com点击某个链接

11、下载与断点续传【-c -O】

curl -c -O http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG -c 断点续传-O 下载图片,文件名为服务器设置的文件名

12、上传文件【-T】

curl -T localfile -u name:passwd ftp://upload_site:port/path/ 向FTP上传文件

参考:http://blog.sina.com.cn/s/blog_4b9eab320100slyw.html

原创粉丝点击