wget批量下载http文件

2018-01-16  本文已影响0人  F_U_N

eg:http://hgdownload.soe.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgDnaseUniform/

下载该路径下的所有文件

wget http://hgdownload.soe.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgDnaseUniform/

得到一个 index.html 文件

然后 

wget -i index.html -F -B http://hgdownload.soe.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgDnaseUniform/

-i file

--input-file=file

          Read URLs from a local or external file.  If - is specified as file, URLs are read from the standard input.  (Use ./- to read from a file literally named -.)

从文件 index.html 中导入链接,默认按行读取URL

-F 

 --force-html 

When input is read from a file, force it to be treated as an HTML file. This enables you to retrieve relative links from existing HTML files on your local disk, by adding "" to HTML, or using the --base command-line option.

将文件以HTML格式解析,(其实就是解析<a>?)<a> 代表链接

-B URL

--base=URL

          Resolves relative links using URL as the point of reference, when reading links from an HTML file specified via the -i/--input-file option (together with --force-html, or when the input file was fetched remotely from a server describing it as HTML). This is equivalent to the presence of a "BASE" tag in the HTML input file, with URL as the value for the "href" attribute.

因为发现解析出来的链接用的都是相对路径,而为了下载这个文件,必须在相对路径前添加上Base URL,-B就是用来添加Base URL。

来自:http://blog.51cto.com/geekbin/1405252

上一篇下一篇

猜你喜欢

热点阅读