【发布时间】:2018-03-04 13:53:03
【问题描述】:
为什么下面的命令可以从www.example.com下载index.html?
wget --reject-regex .* http://www.example.com/
$ wget --reject-regex .* http://www.example.com/
--2018-03-05 11:21:26-- http://.keystone_install_lock/
Resolving .keystone_install_lock... failed: nodename nor servname provided, or not known.
wget: unable to resolve host address ‘.keystone_install_lock’
--2018-03-05 11:21:26-- http://www.example.com/
Resolving www.example.com... 93.184.216.34
Connecting to www.example.com|93.184.216.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1270 (1.2K) [text/html]
Saving to: ‘index.html’
index.html 100%[=================================================================================================================================================>] 1.24K --.-KB/s in 0s
2018-03-05 11:21:27 (4.49 MB/s) - ‘index.html’ saved [1270/1270]
FINISHED --2018-03-05 11:21:27--
Total wall clock time: 0.4s
Downloaded: 1 files, 1.2K in 0s (4.49 MB/s)
wget 的手册页说
--accept-regex urlregex
--reject-regex urlregex
指定一个正则表达式来接受或拒绝完整的 URL。
并且正则表达式.* 匹配所有内容。 (您可以使用freeformatter.com 进行验证)
我认为wget 下载的所有内容都会因为--reject-regex .* 选项而被拒绝。
.* 匹配 www.example.com,不是吗?
wget 为什么不忽略www.example.com 中的所有内容?
【问题讨论】: