【问题标题】:how do I download a large number of zip files with wget to a url如何使用 wget 将大量 zip 文件下载到 url
【发布时间】:2016-05-12 23:29:16
【问题描述】:

在 url here 有大量的 zip 文件,我需要下载并保存到 test/files/downloads 目录。我在提示符下使用 wget

wget -i http://bitly.com/nuvi-plz -P test/files/downloads

它会将整个页面下载到目录中的一个文件中,然后开始下载每个 zip 文件,但随后会为每个看起来像这样的文件提供 404

2016-05-12 17:12:28--  http://bitly.com/1462835080018.zip
Connecting to bitly.com|69.58.188.33|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://bitly.com/1462835080018.zip [following]
--2016-05-12 17:12:28--  https://bitly.com/1462835080018.zip
Connecting to bitly.com|69.58.188.33|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-05-12 17:12:29 ERROR 404: Not Found.

如何让 wget 正确下载页面上的所有 zip 文件?

【问题讨论】:

  • 你不能。 302 是一个重定向。但新位置没有 zip 文件。
  • 你可以试试wget -i http://feed.omgili.com/5Rh5AMTrc4Pv/mainstream/posts/ -P test/files/downloads

标签: bash shell command-line wget


【解决方案1】:

您需要从 bit.ly 获取重定向,然后下载所有文件。这真的很丑陋,但它确实有效:

wget http://bitly.com/nuvi-plz --server-response -O /dev/null 2>&1 | \
  awk '(NR==1){SRC=$3;} /^  Location: /{DEST=$2} END{ print SRC, DEST}' | sed 's|.*http|http|' | \
while read url; do 
  wget -A zip -r -l 1 -nd $url -P test/files/downloads
done

如果您使用直接链接,这将起作用:

wget -A zip -r -l 1 -nd http://feed.omgili.com/5Rh5AMTrc4Pv/mainstream/posts/ -P test/files/downloads

【讨论】:

猜你喜欢
  • 2017-04-21
  • 1970-01-01
  • 2015-09-12
  • 2017-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多