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

The method of downloading using wget in Linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to download with wget in Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to download with wget in Linux".

Examples of use:

1. Download a single file

The code is as follows:

$wget http://osmond.cn/cdbe/CDBE.zip

2. Download a single file in the background by resuming

The code is as follows:

$wget-bc http://ftp.hostrino.com/pub/centos/5.0/isos/i386/CentOS-5.0-i386-bin-

3. Download only a single HTML file, make sure that all elements that affect the display of the page are downloaded, and re-establish the link

The code is as follows:

$wget-p-k http://osmond.cn/cdbe/manual/index.html

4. Download the entire directory of www.xxx.org/pub/path/

The code is as follows:

Wget-c-r-np-k-L-p www.xxx.org/pub/path/

When downloading. Useful pictures or links to external domain names. Use the-H parameter if you need to download at the same time.

The code is as follows:

Wget-np-nH-r-span-hosts www.xxx.org/pub/path/

-C breakpoint continuation

-r Recursive download, downloading all files in a directory (including subdirectories) of a specified web page

-nd recursive download does not create a layer-by-layer directory, but downloads all files to the current directory

-np does not search upper directories when downloading recursively, such as wget-c-r www.xxx.org/pub/path/

If the parameter-np is not added, other files in the pub directory above path will be downloaded at the same time.

-k convert absolute links to relative links, download the entire site and browse the web offline. It is best to add this parameter.

-L recursion does not enter other hosts, such as wget-c-r www.xxx.org/

If there is a link like this on the site:

Www.yyy.org, without the parameter-L, will be like a burning mountain, will download the www.yyy.org website recursively.

-p download all the files required for the web page, such as pictures, etc.

-A specifies the list of file styles to download, separated by commas

-I is followed by a file indicating the URL to be downloaded

5. Download the contents of the entire website as a local mirror site http://www.xyz.edu.cn

The code is as follows:

$wget-m-L4-t0 http://www.xyz.edu.cn

Or

The code is as follows:

Wget-r-p-np-k http://dsec.pku.edu.cn/~usr_name/

6. Download only the directories specified by the website, avoid spreading to other directories on the remote host, and refuse to download gif and jpg files

The code is as follows:

$wget-r-L-R gif,jpg http://www.xyz.edu.cn/doc/

7. Download the blog and wiki directories under http://www.xyz.edu.cn recursively and save the files as html

The code is as follows:

$wget-r-k-p-np-E-I blog,wiki http://www.xyz.edu.cn

8. Recursively download all files of http://ayo.freshrpms.net/redhat/9/i386/updates/RPMS to the current directory

The code is as follows:

$wget-r-nH-nd http://ayo.freshrpms.net/redhat/9/i386/updates/RPMS

9. Batch download (first, write a line for each URL of the file to be downloaded to generate the file download.txt)

The code is as follows:

$wget-I download.txt-o download.log

10. Use the agent to download

The code is as follows:

$wget-Y-I download.txt-o download.log

The agent can be set in the environment variable or in the wgetrc file

How to set up a proxy

The code is as follows:

# set the proxy in the environment variable

Export PROXY= http://214.97.161.94:80/

# set proxy in ~ / .wgetrc

Http_proxy = http://214.97.161.94:80/

Ftp_proxy = http://214.97.161.94:80/

11.* download a partially downloaded file on an unstable network and download it during free time

The code is as follows:

Wget-t 0-w 31-c http://dsec.pku.edu.cn/BBC.avi-o down.log &

# or read the list of files to download from filelist

Wget-t 0-w 31-c-B ftp://dsec.pku.edu.cn/linuxsoft-I filelist.txt-o

Down.log &

At this point, I believe you have a deeper understanding of "the method of downloading using wget in Linux". 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

Servers

Wechat

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

12
Report