当301/302重定向时,Wget无法检测文件名。例如,要从http://www.mysql.com/downloads/mirror.php?id=408580下载MySQL源代码
wget http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/该文件将另存为index.html
wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz该文件将另存为mysql-5.5.25a-linux2.6-x86_64.tar.gz
但第一个url只是第二个URL的重定向,如中所示:
curl -I http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/
HTTP/1.1 302 Found
Date: Mon, 09 Jul 2012 06:11:50 GMT
Server: Apache/2.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: mirror=http%3A%2F%2Fcdn.mysql.com%2F; expires=Sat, 08-Jul-2017 06:11:50 GMT; path=/
Location: http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8wget如何自动将http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/保存为".tar.gz“(不使用-O参数)?
发布于 2012-07-09 14:54:45
尝试执行以下命令:
wget --content-disposition http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/当此选项设置为on时,将启用对"Content-Disposition“标头的实验性(非全功能)支持。这可能会导致"HEAD“请求到服务器的额外往返,并且已知存在一些bug,这就是当前默认情况下未启用它的原因。
此选项对于某些文件下载CGI程序非常有用,这些程序使用"Content-Disposition“头来描述下载文件的名称。
https://stackoverflow.com/questions/11389933
复制相似问题