Copy Code code as follows:
#!/bin/env Bash
Path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
Export PATH
Clear
Url= "http://mirrors.cnnic.cn/apache/"
Downlistfile= "/tmp/downlist.txt"
Downlisttmpfile= "/tmp/tmplist.txt"
Downfiletype= "zip$|gz$"
Downlist= ""
urlback= "$Url"
[!-F $DownListFile] && Touch $DownListFile | | echo > $DownListFile
[!-F $DownListTmpFile] && Touch $DownListTmpFile | | echo > $DownListTmpFile
Curl_urls () {
urls= ' Curl $UrlBack |awk-f ' a href=\ ' ' {printf '%s\n ', $} ' |awk-f ' \ ' ' ' {printf '%s\n ',} ' |grep-ve ' ^$|^\?| ^http:\/\/"|^# '
}
Url_list () {
Curl_urls
For i in $Urls;d o
echo "$UrlBack $i" >> $DownListTmpFile
Done
}
Recursive_search_url () {
Urlbacktmps= ' Cat $DownListTmpFile '
[[' $UrlBackTmps ' = = ']] && echo ' No More page for search ' && exit 1
For j in $UrlBackTmps;d O
if [[[${j##*\/} '!= ']]; then
echo "$j" >> $DownListFile
Else
urlback= "$j"
Url_list
Fi
urltmps= ' grep-ve ' $j $ ' $DownListTmpFile '
echo "$UrlTmps" > $DownListTmpFile
Recursive_search_url
Done
}
Download_file () {
downlist= ' grep-e ' $DownFileType "$DownListFile"
For k in $DownList;d o
filepath=/tmp/${k#*\/\/}
[!-d ' dirname $FilePath '] && mkdir-p ' dirname $FilePath '
[!-F $FilePath] && CD ' dirname $FilePath ' && Curl-o $k
Done
}
Url_list $Urls
Recursive_search_url