当前位置:网站首页>How to download files using WGet and curl
How to download files using WGet and curl
2022-07-04 18:25:00 【Hua Weiyun】
Usually use wget To download files . On some systems , No installation wget, Only curl You can use . Can I use a simple example to explain how I use curl Download remote files ?curl and wget Is there any difference between ?
At a high level ,wget and curl Are command line utilities that perform the same operation .
- They can all be used FTP and HTTP(s) Download the file .
- You can also use it curl and wget send out HTTP POST request
- however curl Provides for programmers to use in their own code API.curl Use libcurl, It is a cross platform library .
- wget Just one without any API Command line tools for .
- Curl Also support more wget Protocol not supported . for example :SCP、SFTP、TFTP、TELNET、LDAP(S)、 file 、POP3、IMAP、SMTP、RTMP and RTSP.
- Use wget There is one major advantage .wget Support recursive download , and curl I won't support it .
wget Example
The following example downloads the file and stores it under the same name as the remote server .
wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
The following example downloads the file and stores it under a different name than the remote server . When remote URL It doesn't contain url File name in , It's very useful , As shown in the following example .
wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701
Curl example
$ curl -O http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 28 3762k 28 1085k 0 0 72771 0 0:00:52 0:00:15 0:00:37 54267
Options -O( Capitalization O) Very important . Without this ,curl Dump the downloaded file to standard output . Use -O, It will download a file with the same name as the remote server . In the example above , We are downloading strx25-0.9.2.1.tar.bz2, So the downloaded file will also have the same name .
except -O, You can also specify “--remote-name”, As shown below . Both are the same .
$ curl --remote-name http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
stay curl When the download , It will provide the following useful information :
- % – The total percentage of downloads completed so far . When it reaches 100% when , Download complete . In the example above , It only downloads 28% The file of .
- Total – Total file size
- Received - Total size of files downloaded so far . In the example above , It has been downloaded so far 1085k( in total 3762k)
- Xferd – This will be used when you upload some files to the remote server . During upload , This will indicate the total size of the files uploaded so far . Because we are downloading a file , In this case , This is a 0.
- Average Speed Dload – This represents the average download speed .
- AVerage Speed Upload – When uploading files , This will indicate the average upload speed
- Time Total – This means that according to the current download ( Or upload ) Speed download ( Or upload ) The total time required for the entire document . In this example , It takes about... To download this file in total 52 second .
- Time Spend – curl Download so far ( Or upload ) The time it takes to file . In this case , So far it has cost 15 second .
- Time Left – That's according to a “ Total time ”——“ Time spent ” Calculated .
- Current Speed – - This indicates the current download / Upload speed . Compare this with average acceleration Dload/UPload Compare , To see how fast or slow your system is currently downloading .
If you want to download a file and store it in a name different from the file name in the remote server , Please use -o( A lowercase letter o), As shown below . When remote URL It doesn't contain url File name in , It's very useful , As shown in the following example .
$ curl -o taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 50243 100 50243 0 0 170k 0 --:--:-- --:--:-- --:--:-- 400k
In the example above , long-range URL No file name in , It just calls a php Script , Pass some parameters to it . however , The file will be downloaded and saved as taglist.zip. Instead of -o, You can also specify “–output”.
边栏推荐
- 用于图数据库的开源 PostgreSQL 扩展 AGE被宣布为 Apache 软件基金会顶级项目
- 通过事件绑定实现动画效果
- regular expression
- Li Kou brush question diary /day7/2022.6.29
- The money circle boss, who is richer than Li Ka Shing, has just bought a building in Saudi Arabia
- Mathematical analysis_ Notes_ Chapter 7: differential calculus of multivariate functions
- 【Hot100】31. Next spread
- Make a grenade with 3DMAX
- 如何提高开发质量
- With the stock price plummeting and the market value shrinking, Naixue launched a virtual stock, which was deeply in dispute
猜你喜欢
要上市的威马,依然给不了百度信心
Li Kou brush question diary /day8/7.1
2022 national CMMI certification subsidy policy | Changxu consulting
uni-app与uviewUI实现仿小米商城app(附源码)
Unity makes revolving door, sliding door, cabinet door drawer, click the effect of automatic door opening and closing, and automatically play the sound effect (with editor extension code)
力扣刷題日記/day6/6.28
谷粒商城(一)
Li Kou brush question diary /day5/2022.6.27
The block:usdd has strong growth momentum
MySQL common add, delete, modify and query operations (crud)
随机推荐
Summary of subsidy policies across the country for dcmm certification in 2022
MySQL common add, delete, modify and query operations (crud)
Open source PostgreSQL extension age for graph database was announced as the top-level project of Apache Software Foundation
Android uses sqliteopenhelper to flash back
五千字讲清楚团队自组织建设 | Liga 妙谈
要上市的威马,依然给不了百度信心
表情包坑惨职场人
General environmental instructions for the project
基于NCF的多模块协同实例
LD_ LIBRARY_ Path environment variable setting
Interview summary of large factory Daquan II
You should know something about ci/cd
力扣刷题日记/day2/2022.6.24
爬虫初级学习
Tutorial on the use of Huawei cloud modelarts (with detailed illustrations)
Machine learning concept drift detection method (Apria)
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
TCP waves twice, have you seen it? What about four handshakes?
使用3DMAX制作一枚手雷
Weima, which is going to be listed, still can't give Baidu confidence