Debian

wget 將 tgz 文件轉換為 HTML

  • April 14, 2017

我正在嘗試在 debian 下下載一個*.tgz*文件,所以我決定使用wget它。這是我的命令行:

~$ wget http://www.netmet-solutions.org/download/netMETdistrib-4.5_5.8_20160322.tgz

我得到了文件,我想tar所以我做

~$ tar -zxvf netMETdistrib-4.5_5.8_20160322.tgz

它說

gzip: stdin: not in gzip format

所以我檢查了文件,這齣現了

netMETdistrib-4.5_5.8_20160322.tgz: HTML document, ISO-8859 text, with very long lines

wget用 HTML轉換了一個tgz文件,我不知道為什麼。

有任何想法嗎?謝謝

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'

**編輯:**基本上,您必須接受 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

,其中生成的文件將被辨識為 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

引用自:https://unix.stackexchange.com/questions/358965