当前位置:网站首页>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”.
边栏推荐
- Weima, which is going to be listed, still can't give Baidu confidence
- The top half and bottom half of the interrupt are introduced and the implementation method (tasklet and work queue)
- Is it safe to open an account online? is that true?
- 未来几年中,软件测试的几大趋势是什么?
- TCP两次挥手,你见过吗?那四次握手呢?
- Lua EmmyLua 注解详解
- I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
- DB-Engines 2022年7月数据库排行榜:Microsoft SQL Server 大涨,Oracle 大跌
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- Easy to use map visualization
猜你喜欢
Reptile elementary learning
Thawte通配符SSL证书提供的类型有哪些
Mysql5.7 installation tutorial graphic explanation
Li Kou brush question diary /day8/7.1
DB-Engines 2022年7月数据库排行榜:Microsoft SQL Server 大涨,Oracle 大跌
Journal des problèmes de brosse à boutons de force / day6 / 6.28
曾经的“彩电大王”,退市前卖猪肉
MySQL常用增删改查操作(CRUD)
Make a grenade with 3DMAX
Tutorial on the use of Huawei cloud modelarts (with detailed illustrations)
随机推荐
Lua emmylua annotation details
Initial experience of domestic database tidb: simple and easy to use, quick to start
【211】go 处理excel的库的详细文档
S5PV210芯片I2C适配器驱动分析(i2c-s3c2410.c)
机器学习概念漂移检测方法(Aporia)
Thawte通配符SSL证书提供的类型有哪些
Tutorial on the use of Huawei cloud modelarts (with detailed illustrations)
比李嘉诚还有钱的币圈大佬,刚在沙特买了楼
能源行业的数字化“新”运维
Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
Just today, four experts from HSBC gathered to discuss the problems of bank core system transformation, migration and reconstruction
SIGMOD’22 HiEngine论文解读
五千字讲清楚团队自组织建设 | Liga 妙谈
高中物理:力、物体和平衡
创业两年,一家小VC的自我反思
ISO27001认证办理流程及2022年补贴政策汇总
Li Kou brush question diary /day6/6.28
Detectron2 installation method
How to improve development quality
Android uses sqliteopenhelper to flash back