wget使用方法(some)
前提说明:
Web服务器http://127.0.0.1:8333/test.php 是我自己搭建的一台nginx+phpweb服务器
1 post请求
Wget默认发送Get请求,通过指定参数--post-dataor --post-file 这两个选项
e.g wget--post-data "aaaa" http://127.0.0.1:8333/test.php
wget--post-data "user=foo" http://127.0.0.1:8333/test.php
wget–post-file post_file http://127.0.0.1:8333/test.php
2 head请求
wget --debug--spider http://127.0.0.1:8333/test.php
--spider并不下载文件,通过head请求服务器,获取web服务器响应
3 –no-cache禁用缓存
e.g wget–no-cache http://127.0.0.1:8333/test.php
请求数据包头部Pragma:no-cache,不使用缓存,http1.1加上Cache-Control: no-cache, must-revalidate
4 –referer使用referer
Referrer主要用户点击的上一个页面,一般可以用做防盗链技术,防盗链可以在url后面加一个key=value加密字段,或者使用特定referer字段。
e.g wget–debug –referer www.baidu.com http://127.0.0.1:8333/test.php
5 显示wget帮助和版本信息
Wget –v or wget –h
6 –e 就是执行命令
e.g wget-e "postdata=111111111" http://localhost:8333/test.php
这种形式和wget –post-data=”11111111” http://localhost:8333/test.php是相同的。
7 logfile (-o)把debug信息输出到文件
e.g wget http://localhost:8333/test.php -ologfile
8 referer设置
e.g wget --debug --referer "www.baidu.com/dsadsa" www.baidu.com/index.html