Wget使用
http://www.tuicool.com/articles/A7BRny
wget / curl 是两个比较方便的测试http功能的命令行工具,大多数情况下,测试http功能主要是查看请求响应 头信息 ,而给这两个工具加上适当的命令行参数即可轻易做到,其实查man手册就能找到对应的参数选项,不过这里仍然mark一下。
wget的debug选项:
–debug
Turn on debug output, meaning various information important to the developers of
Wget if it does not work properly. Your system administrator may have chosen to
compile Wget without debug support, in which case -d will not work. Please note
that compiling with debug support is always safe—Wget compiled with the debug
support will not print any debug info unless requested with -d.
实例(可以看到,wget链接请求默认采用的是HTTP/1.0协议):
[root@localhost ~]# wget 127.0.0.1 --debug
DEBUG output created by Wget 1.12 on linux-gnu. --2012-05-26 12:32:08-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
Created socket 3.
Releasing 0x09cdfb18 (new refcount 0).
Deleting unused 0x09cdfb18. ---request begin---
GET / HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 127.0.0.1
Connection: Keep-Alive ---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Sat, 26 May 2012 04:32:08 GMT
Content-Type: text/html
Content-Length: 186
Last-Modified: Fri, 25 May 2012 02:41:59 GMT
Connection: keep-alive
Accept-Ranges: bytes ---response end---
200 OK
Registered socket 3 for persistent reuse.
Length: 186 1
Saving to: “index.html.42” 100%[================================================================>] 186 --.-K/s in 0s 2012-05-26 12:32:08 (4.72 MB/s) - “index.html.42” saved [186/186] [root@localhost ~]#
如果wget不带–debug选项,则可以使用-S、–save-headers选项,不过此时只能查看响应头部信息:
-S
–server-response
Print the headers sent by HTTP servers and responses sent by FTP servers.
–save-headers
Save the headers sent by the HTTP server to the file, preceding the actual contents,
with an empty line as the separator.
实例:
[root@localhost ~]# wget -S 127.0.0.1
--2012-05-26 12:38:32-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Sat, 26 May 2012 04:38:32 GMT
Content-Type: text/html
Content-Length: 186
Last-Modified: Fri, 25 May 2012 02:41:59 GMT
Connection: keep-alive
Accept-Ranges: bytes
Length: 186 1
Saving to: “index.html.44” 100%[================================================================>] 186 --.-K/s in 0s 2012-05-26 12:38:32 (4.52 MB/s) - “index.html.44” saved [186/186] [root@localhost ~]#
利用curl的-v查看请求响应头部信息:
-v/–verbose
Makes the fetching more verbose/talkative. Mostly useful for debugging. A line
starting with ’>’ means “header data” sent by curl, ’
<
’ means "header data"
received by curl that is hidden in normal cases, and a line starting with ’*’
means additional info provided by curl.
Note that if you only want HTTP headers in the output, -i/--include might be the
option you’re looking for.
If you think this option still doesn’t give you enough details, consider using
--trace or --trace-ascii instead.
This option overrides previous uses of --trace-ascii or --trace.
Use -s/--silent to make curl quiet.
实例(可以看到,wget链接请求默认采用的是HTTP/1.1协议):
[root@localhost aa]# curl -v 127.0.0.1
* About to connect() to 127.0.0.1 port 80 (#0)
* Trying 127.0.0.1… connected
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (i686-pc-linux-gnu) libcurl/7.19.7 NSS/3.12.7.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host: 127.0.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.2.0
< Date: Sat, 26 May 2012 04:45:12 GMT
< Content-Type: text/html
< Content-Length: 186
< Last-Modified: Fri, 25 May 2012 02:41:59 GMT
< Connection: keep-alive
< Accept-Ranges: bytes
<
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
<center><h1>root:web</h1></center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
[root@localhost aa]#
利用curl的-I选项仅查看响应头部信息:
-I/--head
(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD
which this uses to get nothing but the header of a document. When used on a FTP
or FILE file, curl displays the file size and last modification time only.
实例:
[root@localhost aa]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Sat, 26 May 2012 04:43:12 GMT
Content-Type: text/html
Content-Length: 186
Last-Modified: Fri, 25 May 2012 02:41:59 GMT
Connection: keep-alive
Accept-Ranges: bytes [root@localhost aa]#
Wget使用的更多相关文章
- wget 显示"英国中部时间",去掉烦人的刷屏显示
wget下载文件显示多行,进度条后面显示英国中部时间,非常让人郁闷. 本来英文是eta(Estimated Time of Arrival 预计到达时间),翻译错了,干脆去掉好了. 先要有两个个工具 ...
- 好用的wget命令从下载添加环境变量到各参数详解
本文是因为(笔者使用的windows系统)使用过好几次wget后,始终存在各种细节问题,于是下定决定细致的研究一下,并记录下其中细节. 下载与安装 第一步:下载wget,网络地址:http://dow ...
- wget 断点续传 & nginx文件服务器
nginx默认支持断点续传: 测试方法: wget -S http://httpd.apache.org/images/httpd_logo_wide_new.png 2>&1 | gr ...
- Axel替代wget
Axel替代wget 2011年11月10日admin发表评论阅读评论 Linux下用的最多的下载工具莫过于wget和curl,这两个工具虽然堪称经典.但其单线程的速度越来越不能大软件的下载.于是 ...
- 使用wget命令时发生错误
用的是centos6.5, 当我使用命今 sudo wget https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz 下载个cmake的包时, 发生了这样的错误 ...
- wget 扒站
在Linux下,通过一个命令就可以把整个站相关的文件全部下载下来. wget -r -p -k -np [网址] 参数说明: -r : 递归下载 -p : 下载所有用于显示 HTML 页面的图片之类的 ...
- 使用WGET参数介绍大全
wget 是一个命令行的下载工具.对于我们这些 Linux 用户来说,几乎每天都在使用它.下面为大家介绍几个有用的 wget 小技巧,可以让你更加高效而灵活的使用 wget. $ wget -r -n ...
- 用wget命令下载jdk
Oracle官网上下载jdk,需要点击accept licence的才能下载,使用下面的命令,直接可以下载.wget --no-check-certificate --no-cookies --hea ...
- [No00006B]方便的网络下载工具wget 可下载网站目录下的所有文件(可下载整个网站)
wget是linux下命令行的下载工具,功能很强大,它能完成某些下载软件所不能做的,比如如果你想下载一个网页目录下的所有文件,如何做呢?网络用户有时候会遇到需要下载一批文件的情况,有时甚至需要把整个网 ...
- Linux网络下载命令 wget 简介
wget 是一个命令行的下载工具.对于我们这些 Linux 用户来说,几乎每天都在使用它.下面为大家介绍几个有用的 wget 小技巧,可以让你更加高效而灵活的使用 wget. $ wget -r -n ...
随机推荐
- POJ-1001 Exponentiation 高精度算法
题目链接:https://cn.vjudge.net/problem/POJ-1001 以前写过一个高精度乘法,但是没有小数点,实现起来也没什么难得, 现在把代码都般过来,等会把旧电脑弄一弄,暂时就不 ...
- Python学习笔记(2)--基本数据类型
在介绍基本数据类型之前,先说一个系统方法type():返回对象的数据类型,可以帮助我们查看系统的类型定义 python不同的版本,类型名称稍有不同,这里使用的是3.5.2版本 一.基本数据类型: 1. ...
- Unity C# 设计模式(七)适配器模式
定义: 将一个类的接口转换成客户希望的另一个接口.adapter模式使得原本由于接口不兼容而不能在一起的那些类可以一起工作. 示例代码: 1.类适配器 /* Class Adapter:类适配器,这里 ...
- C#日期控件datetimepicker保存空值方法
方法一(推荐): 设置datetimepicker的属性ShowCheckBox为true 在窗口初始化时候,添加代码this.datetimepicker1.Checked = false; 保存日 ...
- ArcGIS api for javascript——查询,立刻打开信息窗口
描述 本例展示了当一个要素被查询时如何立刻打开一个InfoWindow.信息窗口能被用来将要素的属性格式化成用户易读的格式. 本例中,地图和查询任务都使用ESRI sample server上的服务K ...
- Units are seconds since 1970.
在Android实际开发过程中常常会碰到以秒为单位的日期.这时能够依据须要将他们进行格式化处理,详细过程例如以下: long seconds=Long.parseLong("14058896 ...
- Ubuntu下安装git工具
环境:Ubuntu 9.10 git-1.8.2.3.tar.bz2 1.将安装包下载到所选文件夹下,如:/tmp 2.tar -xjf git-1.8.2.3.tar.bz2 3.cd git-1. ...
- 算法导论————EXKMP
[例题传送门:caioj1461] [EXKMP]最长共同前缀长度 [题意]给出模板串A和子串B,长度分别为lenA和lenB,要求在线性时间内,对于每个A[i](1<=i<=lenA), ...
- 22.IntelliJ IDEA 切换 project
转自:https://blog.csdn.net/qwdafedv/article/details/73838628?utm_source=blogxgwz0 1.file->open 2.选择 ...
- Linux系统安全加固(一)
Linux系统安全加固(一) 去年8月,某所网站遭黑客攻击瘫痪虽然港交所随后及时启用备用系统,但还是致使7支股票1支债卷被迫停牌,次日再次遭受攻击而瘫痪:在去年年底继CSDN信息安全出现之后, ...