国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Linux > 正文

使用curl遞歸下載軟件腳本分享

2019-10-26 18:39:26
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

代碼如下:
#!/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",$2}'|awk -F "/"" '{printf "%s/n",$1}'|grep -vE "^$|^/?|^http:////"|^#`
}
URL_LIST(){
 CURL_URLS
 for i in $Urls ;do
  echo "$UrlBack$i" >> $DownListTmpFile
 done
}
RECURSIVE_SEARCH_URL(){
 UrlBackTmps=`cat $DownListTmpFile`
 [[ "$UrlBackTmps" == "" ]] && echo "no more page for search" && exit 1
 for j in $UrlBackTmps ;do
  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 ;do
  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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 和顺县| 通江县| 青岛市| 平原县| 蒲江县| 南昌市| 勐海县| 道孚县| 沾益县| 玛纳斯县| 漠河县| 招远市| 香格里拉县| 九龙城区| 昔阳县| 合江县| 利川市| 渑池县| 奉节县| 宁陕县| 罗甸县| 府谷县| 龙泉市| 平定县| 怀化市| 拜城县| 桐城市| 曲靖市| 乐安县| 姚安县| 方山县| 南平市| 大关县| 巨野县| 新乡市| 永嘉县| 谢通门县| 胶州市| 浙江省| 凤冈县| 丰台区|