wget 将 tgz 文件转换为 HTML

kla*_*pez 0 debian wget file-types

我正在尝试在 debian 下下载一个.tgz文件,所以我决定使用wget它。这是我的命令行:

~$ wget http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz
Run Code Online (Sandbox Code Playgroud)

我得到了文件,我想压缩,所以我做

~$ tar -zxvf netMETdistrib-4.5_5.8_20160322.tgz
Run Code Online (Sandbox Code Playgroud)

它说

gzip: stdin: not in gzip format
Run Code Online (Sandbox Code Playgroud)

所以我检查了文件,这出现了

netMETdistrib-4.5_5.8_20160322.tgz: HTML document, ISO-8859 text, with very long lines
Run Code Online (Sandbox Code Playgroud)

wget在 HTML 中转换了一个tgz文件,我不知道为什么。

有任何想法吗?谢谢

d3a*_*g0s 5

http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz强制重定向到http://www.netmet-solutions.org/Telechargement/Telechargement(标准 HTML 页面)。所以基本上,您下载的不是 .tgz 文件,而是一个简单的 HTML 页面。wget 的输出确认重定向:

? wget http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz
--2017-04-14 11:14:43--  http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz
Resolving www.netmet-solutions.org... 193.50.27.134
Connecting to www.netmet-solutions.org|193.50.27.134|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: /Telechargement/Telechargement [following]
--2017-04-14 11:14:44--  http://www.netmet-solutions.org/Telechargement/Telechargement
Connecting to www.netmet-solutions.org|193.50.27.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `netMETdistrib-4.5_5.8_20160322.tgz'
Run Code Online (Sandbox Code Playgroud)

编辑:基本上,您必须接受 CeCILL 许可证才能下载存档 ( http://www.netmet-solutions.org/Telechargement/Jaccepte )。要通过 wget 执行此操作,您需要在标头中传递预期的 cookie:

wget --no-cookies --header "Cookie: accepted_licence=chocolat" http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz
Run Code Online (Sandbox Code Playgroud)

,其中结果文件将被识别为 gzip 压缩数据:

? file netMETdistrib-4.5_5.8_20160322.tgz
netMETdistrib-4.5_5.8_20160322.tgz: gzip compressed data, last modified: Tue Mar 22 12:39:36 2016, from Unix
Run Code Online (Sandbox Code Playgroud)