wget下载 curl详解

2015-04-18 16:19:00
admin
原创 3505
摘要:wget下载 curl详解

一、wget下载

普通下载:wget url

继续上次下载:wget -c url


递归下载: wget -r -np --reject=html url

-r,递归下载当前页面所有子链接;
-l number,递归深度,默认为5;
-np,表示不去遍历父目录内容;
--reject=html,不接受扩展名为html的文件;
--accept=iso,c,h,只接受这些扩展名的文件,分隔符为逗号;


二、curl详解(可重复使用参数,如需要多个头部字段)

GET请求: curl "www.3scard.com/index.php?m=blog&f=index"


POST请求:Content-Type: application/x-www-form-urlencoded; charset=UTF-8
curl --data "name=feinen" http://211.149.156.144:8080/springmvc/test_post.do

curl --data-urlencode "name=feinen" http://211.149.156.144:8080/springmvc/test_post.do


获取http状态码,取不到时返回000

curl -s -I -m 10 -w "%{http_code}\n" -o /dev/null  www.3scard.com


上传下载文件,表单类型是multipart/form-data

curl -v -L -e ";auto" -F submit=convert -F file=@my.data http://ip:port/convert.do -o outfile


常用参数:

-0,强制使用HTTP/1.0

-s/--silent,安静模式;

-v,显示请求头、响应头;

--trace-ascii,显示请求头、响应头、数据数量、数据;

--trace-time,显示消息时间戳;

-m/--connect-timeout,超时设置,单位为秒;

-I/--head,只取响应头;

-i/--include,输出响应头;

-w/--write-out <format>,设置输出内容格式;

-X method,设置请求方法,比如GET、POST;

-F/--form <name=content>,设置表单类型multipart/form-data;

-H/--header <header>,设置请求头,比如-H "Content-Type: text/html; charset=UTF-8";

-L/--location,This option will make curl redo  the  request on  the  new place;

-e/--referer,通常和-L一起使用;

发表评论
评论通过审核之后才会显示。