WGET and CURL
WGET and CURL
对比
CURL 和WGET都可以用来下载文件,用法也类似:curl/wget [-option...] [url..]
但两者还是有区别的
|对比||
|--|--|
|curl| 1. curl是LInux下的数据传输工具,可以通过URL想服务器上传数据,或者从服务器下载数据。curl支持HTTP、FTP、SMTP、RSTP等应用层协议。 2. curl参数更多更复杂,需要依赖libcurl库,可以把 cURL 想象成一个精简的命令行网页浏览器。它支持几乎你能想到的所有协议,可以交互访问几乎所有在线内容。唯一和浏览器不同的是,cURL 不会渲染接收到的相应信息
|wget |wget是Linux系统中的文件下载命令, 支持HTTP、FTP等协议。 wget是非交互性的,且具有自动下载功能, 能自己在后台工作。 也就是说在用户logout之后,wget仍然能够继续完成自己的工作。 wget更简单,不依赖其他的库,且没有那么多的复杂参数|
wget
| 参数 | 解释 |
|---|---|
| -d: | 调试模式 -d参数能够打印出wget运行时的调试信息:如HTTP报文头等。这个参数非常有用。 |
| -O: | 指定本地文件名 wget www.sina.com -O sina.html表示将www.sina.com 的内容下载到sina.html。 |
| -b: | 后台运行 wget运行在后台,用户logout之后仍能继续下载 |
curl
| 参数 | 用法 | 详解 |
|---|---|---|
| -o | 传输到指定文件,也就是要指定文件名 | eg:curl -o baidu_index.html www.baidu.com可以将百度首页的html源码保存到baidu_index.html文件中 |
| -O | 使用url默认文件名传输 | eg:curl -O http://img.wallpapersking.com/800/2012-8/20120812103710.jpg 直接将图片保存到本地文件20120812103710.jpg |
| -A | --user-agent | 设置用户代理发送给服务器 |
| -b | --cookie <name=string/file> | cookie字符串或文件读取位置 |
| -c小写c | --cookie-jar | 操作结束后把cookie写入到这个文件中 |
| -C大写C | --continue-at | 断点续转 |
| -D | --dump-header | 把header信息写入到该文件中 |
| -e | --referer | 来源网址 |
| -f | --fail | 连接失败时不显示http错误 |
| -o | --output | 把输出写到该文件中 |
| -O | --remote-name | 把输出写到该文件中,保留远程文件的文件名 |
| -r | --range | 检索来自HTTP/1.1或FTP服务器字节范围 |
| -s | --silent | 静音模式。不输出任何东西 |
| -T | --upload-file | 上传文件 |
| -u | --user <user[:password]> | 设置服务器的用户和密码 |
| -w | --write-out [format] | 什么输出完成后 |
| -x | --proxy <host[:port]> | 在给定的端口上使用HTTP代理 |
| -# | --progress-bar | 进度条显示当前的传送状态 |
curl使用示例
下载docker compose包到指定文件
curl -L https://github.com/docker/compose/releases/download/1.24.0-rc1/docker-compose-Linux-x86_64> /usr/local/bin/docker-compose
|用法|命令|解释|
|--|--|--|
|下载页面: |curl -o index.html http://url.com |
|下载文件并显示简单进度条:|curl -# -o centos6.8.iso http://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso |
|断点续传: |curl -# -o centos6.8.iso -C - http://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso |
|伪造来源页面: |curl -e http://url.com http://B.com | #告诉B目标网站,我是从地址url来的
|伪造代理设备: |curl -url " Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" http://B.com | 告诉B目标网站,我是GOOGLE爬虫蜘蛛" Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"当然其实换成"Mozilla/5.0 AppleWebKit/600 Mobile MicroMessenger/6.0"就是微信内置浏览器
|查看本站的http头: |curl -I http://url.com |输出内容一般为:HTTP/1.1 200 OK;Date: Fri, 25 Nov 2016 16:45:49 GMT;Server: Apache;Set-Cookie: rox__Session=abdrt8vesprhnpc3f63p1df7j4; path=/;...
|设置http请求头: |curl -H "Cache-Control:no-cache" http://url.com |
|发送表单数据: |curl -F "pic=@logo.png" -F "site=aiezu" http://url.com/ |
|发送cookie: |curl -b "domain=url.com" http://url.com
curl退出码
| 退出码 | 错误描述 |
|---|---|
| 1 | Unsupported protocol. This build of curl has no support for this protocol. |
| 2 | Failed to initialize. |
| 3 | URL malformed. The syntax was not correct. |
| 5 | Couldn't resolve proxy. The given proxy host could not be resolved. |
| 6 | Couldn't resolve host. The given remote host was not resolved. |
| 7 | Failed to connect to host. |
| 8 | FTP weird server reply. The server sent data curl couldn't parse. |
| 9 | FTP access denied. The server denied login or denied access to the particular resource or directory you wanted to reach. Most often you tried to change to a directory that doesn't exist on the server. |
| 11 | FTP weird PASS reply. Curl couldn't parse the reply sent to the PASS request. |
| 13 | FTP weird PASV reply, Curl couldn't parse the reply sent to the PASV request. |
| 14 | FTP weird 227 format. Curl couldn't parse the 227-line the server sent. |
| 15 | FTP can't get host. Couldn't resolve the host IP we got in the 227-line. |
| 17 | FTP couldn't set binary. Couldn't change transfer method to binary. |
| 18 | Partial file. Only a part of the file was transferred. |
| 19 | FTP couldn't download/access the given file, the RETR (or similar) command failed. |
| 21 | FTP quote error. A quote command returned error from the server. |
| 22 | HTTP page not retrieved. The requested url was not found or returned another error with the HTTP error code being 400 or above. This return code only appears if -f/--fail is used. |
| 23 | Write error. Curl couldn't write data to a local filesystem or similar. |
| 25 | FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading. |
| 26 | Read error. Various reading problems. |
| 27 | Out of memory. A memory allocation request failed. |
| 28 | Operation timeout. The specified time-out period was reached according to the conditions. |
| 30 | FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT command, try doing a transfer using PASV instead! |
| 31 | FTP couldn't use REST. The REST command failed. This command is used for resumed FTP transfers. |
| 33 | HTTP range error. The range "command" didn't work. |
| 34 | HTTP post error. Internal post-request generation error. |
| 35 | SSL connect error. The SSL handshaking failed. |
| 36 | FTP bad download resume. Couldn't continue an earlier aborted download. |
| 37 | FILE couldn't read file. Failed to open the file. Permissions? |
| 38 | LDAP cannot bind. LDAP bind operation failed. |
| 39 | LDAP search failed. |
| 41 | Function not found. A required LDAP function was not found. |
| 42 | Aborted by callback. An application told curl to abort the operation. |
| 43 | Internal error. A function was called with a bad parameter. |
| 45 | Interface error. A specified outgoing interface could not be used. |
| 47 | Too many redirects. When following redirects, curl hit the maximum amount. |
| 48 | Unknown TELNET option specified. |
| 49 | Malformed telnet option. |
| 51 | The peer's SSL certificate or SSH MD5 fingerprint was not ok. |
| 52 | The server didn't reply anything, which here is considered an error. |
| 53 | SSL crypto engine not found. |
| 54 | Cannot set SSL crypto engine as default. |
| 55 | Failed sending network data. |
| 56 | Failure in receiving network data. |
| 58 | Problem with the local certificate. |
| 59 | Couldn't use specified SSL cipher. |
| 60 | Peer certificate cannot be authenticated with known CA certificates. |
| 61 | Unrecognized transfer encoding. |
| 62 | Invalid LDAP URL. |
| 63 | Maximum file size exceeded. |
| 64 | Requested FTP SSL level failed. |
| 65 | Sending the data requires a rewind that failed. |
| 66 | Failed to initialize SSL Engine. |
| 67 | The user name, password, or similar was not accepted and curl failed to log in. |
| 68 | File not found on TFTP server. |
| 69 | Permission problem on TFTP server. |
| 70 | Out of disk space on TFTP server. |
| 71 | Illegal TFTP operation. |
| 72 | Unknown TFTP transfer ID. |
| 73 | File already exists (TFTP). |
| 74 | No such user (TFTP). |
| 75 | Character conversion failed. |
| 76 | Character conversion functions required. |
| 77 | Problem with reading the SSL CA cert (path? access rights?). |
| 78 | The resource referenced in the URL does not exist. |
| 79 | An unspecified error occurred during the SSH session. |
| 80 | Failed to shut down the SSL connection. |
| 82 | Could not load CRL file, missing or wrong format (added in 7.19.0). |
| 83 | Issuer check failed (added in 7.19.0). |
| XX | More error codes will appear here in future releases. The existing ones are meant to never change. |
本博客为Swagger-Ranger的笔记分享,文中源码地址: https://github.com/Swagger-Ranger
欢迎交流指正,如有侵权请联系作者确认删除: liufei32@outlook.com
WGET and CURL的更多相关文章
- 利用wget 和 curl 监控网站是否正常
监控网站URL是否正常最常见的方法莫过于wget和curl命令了,这两个命令都是非常强大,参数也非常多,下面列举几个常用的参数. wget 常用命令参数:--spider ...
- 44、wget和curl的常用参数
1.wget: wget是文件下载的工具: 不加任何参数是直接下载该文件: (1)-O: 将下载的文件指定为特定的文件名: wget -O baidu.html www.baidu.com --201 ...
- 简单备忘一下Linux下的wget和curl如何使用http proxy
简单备忘一下Linux下的wget和curl如何使用http proxywget -e "http_proxy=porxyhost:port" www.baidu.comcurl ...
- wget和curl方式下载JDK
有时候我们需要在Linux服务器上安装Oracle JDK,这时候我们发现直接复制网页上面的地址是不能下载的 以下载jdk-8u101-linux-i586.tar.gz为例,右键查看到的地址为htt ...
- 测试网站链接是否可用(wget和curl)
一.wget用法案例 系统给的命令参数如下: [root@litong_centos mysql3307]# wget --help GNU Wget 1.14, a non-interactive ...
- wget和curl
1 curl比wget支持更多的协议 2 wget是支持递归的,而curl不支持
- Linux进阶之seq,pidof,wget,curl,tr,grep命令
本节内容 seq pidof wget curl tr grep 1.seq(sequence) 生成数列 例子1:指定结束位置 [root@renyz ~]# seq 5 1 2 3 4 ...
- 39、wget、curl
39.1.wget介绍: wget命令用来从指定的URL下载文件.wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败, wget会不断的尝试,直到整个文件 ...
- curl与wget
curl 和wget 区别 使用方法 可参考 curl vs Wget 1.curl是libcurl这个库支持的,wget是一个纯粹的命令行命令.2.curl支持更多的协议.curl supports ...
随机推荐
- Linux-打包和文件系统
1 文件后缀 在Linux中后缀没有实际意义 2 打包文件 tar c 创建一个归档 v 查看过程 f 指定文件名 t 列出归档内容 x 从归档中解压出文件 C 改变到哪个目录 z gzip压缩 j ...
- rkhunter和chkrootkit
今天继续检查我的Linux,所以下来rkhunter和chkrootkit一个一个来,下面只记录命令,少些说明不截图了. 1.rkhunter #cd /temp #wget http://downl ...
- shell之sort和uniq 及wc 的使用
文本排序:sort -n:数值排序 -r: 降序 -t: 字段分隔符 -k: 以哪个字段为关键字进行排序 -u: 排序后相同的行只显示一次 ...
- 使用 WinSCP(下载) 上文件到 Linux图文教程
问题导读: 1.如何远程链接? 2.如何上传文件? 3.如何对立面的文件进行操作? 4.什么情况下会链接失败? https://yunpan.cn/cYWtNMycjeVPv 访问密码 4f7 ...
- vue.js 组件共用函数的方法之一
如果我现在写一个组件pullMore,想要用到loadMore里面的方法(函数), 那么只需要在当前组件pullMore,script里面先引入组件import loadMore from './lo ...
- Android调试之TraceView
TraceView 在应用运行时,可以使用Debug类打开操作日志记录功能,打开后Android会详细记录应用花在每个线程以及线程的每个函数的调用时间.操作日志记录完毕后,可以使用Android SD ...
- Flutter实战视频-移动电商-19.首页_火爆专区界面布局编写
19.首页_火爆专区界面布局编写 看一下图片的效果 一个标题栏,下面是多行两列.里面可以用column布局,外面用Warp流式布局 有得小伙伴说这里可以用网格布局,网格布局的话还是有一定的效率问题.这 ...
- JAVA企业级开发--jsp,el,jstl(14)
三. EL表达式语言 EL 全名为Expression Language.表达式语言.jsp2.0之后才引入的. EL主要作用:替代:<%= %> out.print(); 获取数 ...
- E20180607-hm
duplicate v. 重复; 复制; 复印; adj. 复制的; 副本的; 完全一样的; n. 副本; 完全一样的东西; 复制品; adjacent adj. 相邻; 邻近的,毗邻 ...
- 进击python第一篇:相遇
1.第一句Python代码 在 当前目录下创建 hello.py 文件,内容如下: print "hello,world!" 执行 hello.py 文件,即: python he ...