The problem of downloading the jdk compressed package in wget mode under Linux is only 5KB

Download jdk-8u201-linux-x64.tar.gz on Linux today using wget ,

wget https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz

After downloading, the file size is only 5.2KB .

ls -lht
-rw-r--r-- 1 root  root  5.2K 3月  21 2012 jdk-15.0.1_linux-x64_bin.tar.gz

Go back and take a closer look at the download information,

--2021-01-02 19:23:19--  https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz
正在解析主机 download.oracle.com (download.oracle.com)... 88.221.164.33
正在连接 download.oracle.com (download.oracle.com)|88.221.164.33|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Moved Temporarily
位置:https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz [跟随至新的 URL]
--2021-01-02 19:23:21--  https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz
正在解析主机 edelivery.oracle.com (edelivery.oracle.com)... 92.122.87.84, 2600:1417:76:582::366, 2600:1417:76:594::366
正在连接 edelivery.oracle.com (edelivery.oracle.com)|92.122.87.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Moved Temporarily
位置:http://download.oracle.com/errors/download-fail-1505220.html [跟随至新的 URL]
--2021-01-02 19:23:23--  http://download.oracle.com/errors/download-fail-1505220.html
正在连接 download.oracle.com (download.oracle.com)|88.221.164.33|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://download.oracle.com/errors/download-fail-1505220.html [跟随至新的 URL]
--2021-01-02 19:23:24--  https://download.oracle.com/errors/download-fail-1505220.html
正在连接 download.oracle.com (download.oracle.com)|88.221.164.33|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:5307 (5.2K) [text/html]
正在保存至: “jdk-15.0.1_linux-x64_bin.tar.gz”

100%[============================================>] 5,307       --.-K/s 用时 0s

2021-01-02 19:23:25 (621 MB/s) - 已保存 “jdk-15.0.1_linux-x64_bin.tar.gz” [5307/5307])

Looking at the last few lines, it is not difficult to find that the download is actually an html failure page https://download.oracle.com/errors/download-fail-1505220.html , and finally saved to jdk-15.0.1_linux-x64_bin.tar.gz middle.

The reason for the failure is Oracle's download restrictions on its resources, so how to wget download the jdk compressed package?

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz
OR
wget --no-check-certificate -c --header="Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.tar.gz

That is, add parameters to wget to make it skip some checks. For details, you can query the introduction of related parameters of wget , as follows:

wget -h
GNU Wget 1.14, a non-interactive network retriever.
Usage: wget [OPTION]... [URL]...

Mandatory arguments to long options are mandatory for short options too.

HTTPS (SSL/TLS) options:
       --no-check-certificate   don't validate the server's certificate.
Download:
  -c,  --continue                resume getting a partially-downloaded file.
HTTP options:
  -E,  --header=STRING         insert STRING among the headers.

Reference article: https://www.cnblogs.com/songzehao/p/10854260.html 

Guess you like

Origin blog.csdn.net/qq_39711485/article/details/112114615