海之飞燕

Menu
  • IOS
  • Swift
  • 前端开发
  • Flutter
  • ReactNative
  • Other
Menu

curl、wget命令下载文件

Posted on 2019年2月1日2019年2月18日 by Herriat
在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具。它支持文件的上传和下载,是综合传输工具,但按传统,习惯称url为下载工具。
语法:# curl [option] [url]
参数:
-A/–user-agent <string>              设置用户代理发送给服务器
-b/–cookie <name=string/file>    cookie字符串或文件读取位置
-c/–cookie-jar <file>                    操作结束后把cookie写入到这个文件中
-C/–continue-at <offset>            断点续转
-D/–dump-header <file>              把header信息写入到该文件中
-e/–referer                                  来源网址
-f/–fail                                          连接失败时不显示http错误
-o/–output                                  把输出写到该文件中
-O/–remote-name                      把输出写到该文件中,保留远程文件的文件名
-r/–range <range>                      检索来自HTTP/1.1或FTP服务器字节范围
-s/–silent                                    静音模式。不输出任何东西
-T/–upload-file <file>                  上传文件
-u/–user <user[:password]>      设置服务器的用户和密码
-w/–write-out [format]                什么输出完成后
-x/–proxy <host[:port]>              在给定的端口上使用HTTP代理
-#/–progress-bar                        进度条显示当前的传送状态
1.基本用法
curl http://www.linux.com
执行后,www.linux.com 的html就会显示在屏幕上了
2、保存访问的网页
2.1:使用linux的重定向功能保存
# curl http://www.linux.com >> linux.html
2.2:可以使用curl的内置option:-o(小写)保存网页
$ curl -o linux.html http://www.linux.com
执行完成后会显示如下界面,显示100%则表示保存成功
2.3:可以使用curl的内置option:-O(大写)保存网页中的文件,会以服务器上的名称保存文件到本地
注意这里后面的url要具体到某个文件
# curl -O http://www.linux.com/hello.sh
wget方式下载文件
1.下载网页
wget www.baidu.com
2.下载图片或者文件
wget https://nginx.org/download/nginx-1.13.3.tar.gz
3.下载文件到指定目录
wget -P /tmp/tomcat/api http://salt-pkg.duobeiyun.com/nebula/script-maintain/web/api/pkg/ROOT.tar.gz

3 thoughts on “curl、wget命令下载文件”

  1. www.scoop.it说道:
    2020年12月10日 上午12:48

    Does your site have a contact page? I’m having a tough
    time locating it but, I’d like to shoot you an e-mail.

    I’ve got some ideas for your blog you might
    be interested in hearing. Either way, great website and I look
    forward to seeing it grow over time.

    回复
  2. smm provider panel说道:
    2020年12月10日 下午2:22

    It’s actually a nice and helpful piece of information. I’m satisfied
    that you just shared this useful information with us.
    Please stay us informed like this. Thanks for sharing.

    回复
    1. Herriat说道:
      2020年12月14日 下午4:14

      Thanks for your comment。

      回复

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

近期文章

  • WKWebView加载H5页面,退出时视频继续播放
  • Swift基础知识总结
  • ReactNative-Linking的基本使用
  • ReactNative进度条ProgressViewIOS
  • ReactNative中react-native-webview与js交互
  • ReactNative-SectionList

近期评论

  • Herriat发表在《curl、wget命令下载文件》
  • smm provider panel发表在《curl、wget命令下载文件》
  • www.scoop.it发表在《curl、wget命令下载文件》
  • 金玉游龙发表在《iOS9 Universal Links》
  • 十一岁的加重发表在《iOS-判断字符串是否是空字符串的方法》

文章归档

功能

  • 登录
  • 项目feed
  • 评论feed
  • WordPress.org

友情链接

金玉游龙 为吾优
©2021 海之飞燕 | WordPress Theme by Superbthemes.com