当前位置:网站首页>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”.
边栏推荐
- [daily question] 556 Next bigger element III
- android使用SQLiteOpenHelper闪退
- Numpy 的仿制 2
- Reptile elementary learning
- 股价大跌、市值缩水,奈雪推出虚拟股票,深陷擦边球争议
- ARTS_ twenty million two hundred and twenty thousand six hundred and twenty-eight
- Mathematical analysis_ Notes_ Chapter 7: differential calculus of multivariate functions
- Superscalar processor design yaoyongbin Chapter 5 instruction set excerpt
- Imitation of numpy 2
- DB-Engines 2022年7月数据库排行榜:Microsoft SQL Server 大涨,Oracle 大跌
猜你喜欢
Neglected problem: test environment configuration management
Is it science or metaphysics to rename a listed company?
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
Once the "king of color TV", he sold pork before delisting
华为云ModelArts的使用教程(附详细图解)
为啥有些线上演唱会总是怪怪的?
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
爬虫初级学习
Grain Mall (I)
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
随机推荐
[HCIA continuous update] WAN technology
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
力扣刷题日记/day7/6.30
"In Vietnam, money is like lying on the street"
【Hot100】31. Next spread
输入的查询SQL语句,是如何执行的?
ITSS运维能力成熟度分级详解|一文搞清ITSS证书
Stars open stores, return, return, return
Neglected problem: test environment configuration management
Li Kou brush question diary /day7/2022.6.29
怎么开户才是安全的,
无心剑中译伊丽莎白·毕肖普《一门技艺》
Reptile elementary learning
【系统分析师之路】第七章 复盘系统设计(结构化开发方法)
曾经的“彩电大王”,退市前卖猪肉
celebrate! Kelan sundb and Zhongchuang software complete the compatibility adaptation of seven products
估值900亿,超级芯片IPO来了
【系统盘转回U盘】记录系统盘转回U盘的操作
Performance test of Gatling
【Go语言刷题篇】Go完结篇|函数、结构体、接口、错误入门学习