Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to download software recursively using curl

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to use curl recursive download software", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use curl to download recursive software.

The code is 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", $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 [["${jackers *\ /}"! = "]]; 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/$ {kink * /\ /}

[!-d `dirname $FilePath`] & & mkdir-p `FilePath`

[!-f $FilePath] & & cd `dirname $FilePath` & & curl-O $k

Done

}

URL_LIST $Urls

RECURSIVE_SEARCH_URL

At this point, I believe you have a deeper understanding of "how to use curl recursive download software". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report