wget 参数--spdier的妙用

参数说明
-T:超时时间
-t:超时重试次数
其余参数:http://man.linuxde.net/wget

[root@db02 scripts]#wget T 10 --spider -t 2 blog.51cto.com
Spider mode enabled. Check if remote file exists.
--2018-07-26 21:15:07--  http://t/
Resolving t... failed: Name or service not known.
wget: unable to resolve host address `t'
Spider mode enabled. Check if remote file exists.
--2018-07-26 21:15:07--  http://10/
Resolving 10... 0.0.0.10
Connecting to 10|0.0.0.10|:80... failed: Invalid argument.
Spider mode enabled. Check if remote file exists.
--2018-07-26 21:15:07--  http://blog.51cto.com/
Resolving blog.51cto.com... 59.110.244.199
Connecting to blog.51cto.com|59.110.244.199|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

wget 的参数--spider不会下载任何东西,spider主要是模拟蜘蛛爬行页面,但却不会下载任何东西,主要用来测试下载链接。根据返回的状态码,判断链接是否可用,“200 OK”表示链接可用。类似curl获取网站的HTTP状态码差不多。
HTTP request sent, awaiting response... 200 OK

使用spider参数的情况
定时下载之前进行检查
间隔检测网是否可用(可做定时任务)
检查网站页面的死链接

猜你喜欢

转载自blog.51cto.com/13691477/2150749
今日推荐