用wget下载文件
wget使用文档:https://www.gnu.org/software/wget/manual/wget.html
最开始常用的比如:
wget -O /e/movie.mp4 http://www.com/m.mp4
输出到e盘的movie.mp4文件:可是 - O 默认会覆盖文件!
所以在最后面加个 -c 表示继续下载。wget -O /e/movie.mp4 -c
wget -P /e/ http://www.com/m.mp4
下载到e盘,文件名保持和url上的一样(m.mp4):
-P 表示下载目录(prefix)
---
翻译了一下文档 wget 1.12的 -c 选项的使用方法。
-c
--continue
Continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program. For instance:
继续只下载了一部分的文件,可以继续 wget 未完成的下载,别的程序未完成的也可以,比如:
wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z
If there is a file named ls-lR.Z in the current directory, Wget will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file.
在当前目录已经有一个lS-IR.Z这个文件的话,它将会被wget当成远程文件的前一部分文件,然后会要求服务器从本地文件大小的位置开始续传。
Note that you don't need to specify this option if you just want the current invocation of Wget to retry downloading a file should the connection be lost midway through. This is the default behavior. -c only affects resumption of downloads started prior to this invocation of Wget, and whose local files are still sitting around.
注意,如果你只是想要在当前调用的wget中途断掉连接后,重试下载文件时续传,你没必要去指定这个选项。它会在重试的时候默认继续下载。-c 只会作用在最开始调用wget,而本地文件已经存在了的时候。
Without -c, the previous example would just download the remote file to ls-lR.Z.1, leaving the truncated ls-lR.Z file alone.
下载的时候不带-c, 之前的例子就会下载远程文件到ls-LS.Z.1,不会影响未下载完全的ls-LS.Z。
Beginning with Wget 1.7, if you use -c on a non-empty file, and it turns out that the server does not support continued downloading, Wget will refuse to start the download from scratch, which would effectively ruin existing contents. If you really want the download to start from scratch, remove the file.
从1.7版开始,如果你使用 -c 在一个不为空的文件上,恰巧服务器又不支持断点续传。wget会拒绝把抓到内容(scratch?)下载到文件,因为再继续下载的话会毁掉已经存在的文件。所以,只有移除文件,然后从头开始下载。
Also beginning with Wget 1.7, if you use -c on a file which is of equal size as the one on the server, Wget will refuse to download the file and print an explanatory message. The same happens when the file is smaller on the server than locally (presumably because it was changed on the server since your last download attempt)---because ``continuing'' is not meaningful, no download occurs.
同样是从1.7 版开始,如果你使用 -c 继续下载一个文件,恰好这个文件的大小和服务器上的一样大,wget会拒绝下载这个文件,然后命令行输出解释信息。同样的,如果服务器上的比本地文件还要小的话(也许自从上次你下载了之后更改过了),继续下载也没有意义了,也不会下载。
On the other side of the coin, while using -c, any file that's bigger on the server than locally will be considered an incomplete download and only "(length(remote) - length(local))" bytes will be downloaded and tacked onto the end of the local file. This behavior can be desirable in certain cases---for instance, you can use wget -c to download just the new portion that's been appended to a data collection or log file.
另一方面,当使用 -c 的时候,服务器的文件比本地文件大的时候都会被认为未完成的下载,只会下载 远程文件长度 减去 本地文件长度 的字节数内容,然后添加到本地文件的后面。 这个方式在大多数情况下是不错的 —— 比如,你可以使用wget -c 只下载数据收集或者日志文件新增的部分。
However, if the file is bigger on the server because it's been changed, as opposed to just appended to, you'll end up with a garbled file. Wget has no way of verifying that the local file is really a valid prefix of the remote file. You need to be especially careful of this when using -c in conjunction with -r, since every file will be considered as an ``incomplete download'' candidate.
然而,如果服务器上的文件比较大,是因为他更改过了,而不是在后面增加了,你将会得到一个没有用的文件。wget是无法验证本地的文件是否是远程文件的前一部分的。当你在和 -r 一起使用的时候,千万小心,因为每个文件都被认为是一个没有完成的下载。
Another instance where you'll get a garbled file if you try to use -c is if you have a lame HTTP proxy that inserts a ``transfer interrupted'' string into the local file. In the future a ``rollback'' option may be added to deal with this case.
另外一种情况,你用 -c 也会得到一个没用的文件:如果你使用不稳定的http代理,将会插入一个“传输中断”的字符串到你的本地文件,在之后的版本会添加“rollback” 选项,以处理这种情况。
Note that -c only works with FTP servers and with HTTP servers that support the "Range" header.
注意 -c 只会在支持“range” 头的ftp服务器和http服务器上使用。
用wget下载文件的更多相关文章
- 多线程爬虫Java调用wget下载文件,独立线程读取输出缓冲区
写了个抓取appstore的,要抓取大量的app,本来是用httpclient,但是效果不理想,于是直接调用wget下载,但是由于标准输出.错误输出的原因会导致卡住,另外wget也会莫名的卡住. 所以 ...
- linux上使用wget下载文件
首次安装的centos操作系统是没有安装wget的,所以首先需要先安装wget,然后才能使用wget下载文件. 1.第一步,保证centos能正常连网.使用命令 :yum -y install wg ...
- CentOS7.5 通过wget下载文件到指定目录
在Linux命令行下面下载文件,通过wget是比较普遍简单的,比如在CentOS7 里面也一样. 我们先来看下自己的CentOS7 系统有没有安装wget: [root@test redis]# rp ...
- wget下载文件
http://blog.sina.com.cn/s/blog_4af3f0d20100n1k0.html 一.下载目录 #wget -r -np -nd http://example.com/pack ...
- CentOS7通过wget下载文件到指定目录
查看自己的CentOS7系统有没有安装wget: [duanyongchun@192 3DUnetCNN]$ rpm -qa|grep wget 已安装提示: #已安装提示:wget-1.14-18. ...
- 利用WGET下载文件,并保存到指定目录
wget是Linux上一个非常不错的下载指令,也算是Linux工作者常用的指令之一 而这个指令我想在各大系统都预设有提供,包括了Ubuntu.Fedora等,而一般来说,要使用wget下载档案,只需要 ...
- wget 下载文件重进行命名
wget在下载的时候就重命名的: wget -c "www.baidu.com" -O baidu.index.html 保存输出日至,可以使用: wget -c "ww ...
- wget 下载文件
# -c 继续执行上次终端的任务# --http-user http用户名# --http-passwd http密码# --no-check-certificate 不检查ssl/tsl证书. wg ...
- wget下载FTP的文件
在Linux中我们怎么样实现wget来下载文件 下面例子 下载所有的py结尾的文件到当前目录 wget ftp://anymous:anymous@42.51.152.2/soft/*.py 递归的 ...
随机推荐
- css3学习总结1--CSS3选择器
CSS3的属性选择器主要包括以下几种: 1. E[attr^="value"]:指定了属性名,并且有属性值,属性值是以value开头的: 2. E[attr$="valu ...
- 标准化css属性顺序
前言 对于css文件而言,选择器的写法有它的讲究,如—— 1> 不要用ID选择器 2> 不要用通配符*选择器 3> 选择器的层级 ...... 对于属性值的写法也有他的讲究,如—— ...
- Struts2中过滤器和拦截器的区别
拦截器和过滤器的区别: 1.拦截器是基于java的反射机制的,而过滤器是基于函数回调 2.过滤器依赖与servlet容器,而拦截器不依赖与servlet容器 3.拦截器只能对action请求起作用,而 ...
- JAVA基础学习之命令行方式、配置环境变量、进制的基本转换、排序法、JAVA文档生成等(1)
1.命令行方式 dos命令行,常见的命令: dir:列出当前目录下的文件以及文件夹 md:创建目录 rd:删除目录 cd:进入指定目录 cd..:退回到上一级目录 cd/:退回到根目录 del:删除文 ...
- STL —— STL六大组件
注:以下内容摘自 http://blog.csdn.net/byxdaz/article/details/4633826 STL六大组件 容器(Container) 算法(Algorithm) 迭代器 ...
- 人生维艰,何不利用开源.NET函数库让工作更轻松
今天推荐的文章会谈到一些让你工作更轻松的开源.NET函数库. 即使业界有时候认为.NET开源社区不太健康,很多开发团队都更多依赖于微软提供的东西来开发.不过最近在.NET世界中还是诞生了一些优秀和有意 ...
- .NET Framework 4.6的新东西
我们知道.NET Framework 4.6即将随着Visual Studio 2015一同到来,目前依然是预览版.4.6和4,4.5,4.5.1和4.5.2是兼容的,也即安装4.6后会升级替代他们. ...
- map与mapPartitions
区别在于sc.map是将RDD下的所有行数据统计处理.而sc.mapPartitions是按RDD分区进行数据统计处理. 测试一下: val data = sc.parallelize(1 to 6, ...
- 克隆或拷贝的VMware虚拟机IP问题解决
克隆的虚拟机或是将虚拟机通过快照回到过去某个状态后,会上不了网. 如果不想看细节,可直接跳到小结部分. 问题描述: 运行service network restart时 Device eth0 doe ...
- Spring的qualifier标签
@Autowired是根据类型进行自动装配的.如果当Spring上下文中存在不止一个UserDao类型的bean时,就会抛出BeanCreationException异常;如果Spring上下文中不存 ...