1. wget –debug
wget可以使用debug信息来查看信息头,如下:
[[email protected] ~]# wget --debug http://192.168.112.129/index.html
DEBUG output created by Wget 1.12 on linux-gnu.
--2017-06-01 10:15:12-- http://192.168.112.129/index.html
Connecting to 192.168.112.129:80... connected.
Created socket 3.
Releasing 0x0000000000e92340 (new refcount 0).
Deleting unused 0x0000000000e92340.
---request begin---
GET /index.html HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 192.168.112.129
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Thu, 01 Jun 2017 02:15:12 GMT
Content-Type: text/html
Content-Length: 23
Last-Modified: Thu, 01 Jun 2017 02:10:40 GMT
Connection: keep-alive
ETag: "592f77a0-17"
Accept-Ranges: bytes
---response end---
200 OK
Registered socket 3 for persistent reuse.
Length: 23 [text/html]
Saving to: “index.html.1”
100%[===================================================================================================================================================>] 23 --.-K/s in 0s
2017-06-01 10:15:12 (2.82 MB/s) - “index.html.1” saved [23/23]
[[email protected] ~]#
2. wget -save-headers
以使用-S、–save-headers选项,不过此时只能查看响应头部信息,注意,debug和save-headers都会输出到文件。
3. wget --spider
判断一个文件或者页面是否存在,可以使用一下命令:
[[email protected] ~]# wget --spider nv http://192.168.112.129/index.html
Spider mode enabled. Check if remote file exists.
--2017-06-01 10:09:08-- http://nv/
Resolving nv... failed: Temporary failure in name resolution.
wget: unable to resolve host address “nv”
Spider mode enabled. Check if remote file exists.
--2017-06-01 10:09:18-- http://192.168.112.129/index.html
Connecting to 192.168.112.129:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3698 (3.6K) [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
[[email protected] ~]#
4. curl -v
可以查看url的文件头信息,如下:
[[email protected] ~]# curl -v http://192.168.112.129/index.html
* About to connect() to 192.168.112.129 port 80 (#0)
* Trying 192.168.112.129... connected
* Connected to 192.168.112.129 (192.168.112.129) port 80 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.112.129
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.10.2
< Date: Thu, 01 Jun 2017 02:10:46 GMT
< Content-Type: text/html
< Content-Length: 23
< Last-Modified: Thu, 01 Jun 2017 02:10:40 GMT
< Connection: keep-alive
< ETag: "592f77a0-17"
< Accept-Ranges: bytes
<
this is a test website
* Connection #0 to host 192.168.112.129 left intact
* Closing connection #0
[[email protected] ~]#
5. curl -I
利用curl的-I(大写i)--head 选项仅查看响应头部信息:
[[email protected] ~]# curl -I http://192.168.112.129/index.html
HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Thu, 01 Jun 2017 02:11:36 GMT
Content-Type: text/html
Content-Length: 23
Last-Modified: Thu, 01 Jun 2017 02:10:40 GMT
Connection: keep-alive
ETag: "592f77a0-17"
Accept-Ranges: bytes
[[email protected] ~]#
6. 获取url的状态码
[[email protected] ~]# curl -o /dev/null -s -w %{http_code} http://192.168.112.129/index.html
200
[[email protected] ~]#