wget and Curl Download JDK

Source: Internet
Author: User
Tags ssl certificate eloqua

Sometimes we need to install Oracle JDK on the server, when we find that the address directly above the copy page is not downloadable.

To download jdk-8u101-linux-i586.tar.gz as an example, right-click to see the address is http://download.oracle.com/otn-pub/java/jdk/8u101-b13/ Jdk-8u101-linux-i586.tar.gz, but this address cannot be downloaded directly

Through the browser development tool, we found that the download was 3 redirects to get the final, and the cookies have a parameter must be brought

Copy these 302 jumps into curl to see

Redirect for the first time

 curl "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/ Jdk-8u101-linux-i586.tar.gz " 
-h" Host:download.oracle.com "-H" user-agent: mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:47.0) gecko/20100101 firefox/47.0 "
-h" accept:text/html,application/ xhtml+xml,application/xml;q=0.9,*/*;q=0.8 "-H" accept-language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 "
Span style= "COLOR: #000000" >--compressed-h "referer:http://www.oracle.com/technetwork/java/javase/downloads/ Jdk8-downloads-2133151.html "
-h" cookie:s_nr=1472257078143; eloqua=guid=e0964a7736384dc98085509e60e04539; S_cc=true; Gpw_e24=http "%" 3 A "%" 2F "%" 2fwww.oracle.com "%" 2Ftechnetwork "%" 2Fjava "%" 2Fjavase "%" 2Fdownloads "%" 2fjdk8-downloads-2133151.html;
s_sq= "%" 5B "%" 5BB "%" 5D "%" 5 D; Oraclelicense=accept-securebackup-cookie "-H" connection:keep-alive "

Second redirect

Curl "https://edelivery.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz"-H "Host: Edelivery.oracle.com "-H" user-agent:mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:47.0) gecko/20100101 firefox/47.0 "-H" accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 "- H "accept-language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"--compressed-h "referer:http://www.oracle.com/technetwork /java/javase/downloads/jdk8-downloads-2133151.html "-H" cookie:aru_lang=us; s_nr=1472257078143; eloqua=guid=e0964a7736384dc98085509e60e04539; S_cc=true; Gpw_e24=http "%" 3 A "%" 2F "%" 2fwww.oracle.com "%" 2Ftechnetwork "%" 2Fjava "%" 2Fjavase "%" 2Fdownloads "%" 2fjdk8-downloads-2133151.html; s_sq= "%" 5B "%" 5BB "%" 5D "%" 5 D; Oraclelicense=accept-securebackup-cookie "-H" connection:keep-alive "third redirect"

curl  "https://edelivery.oracle.com/osdc-otn/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz"   -h  "host: edelivery.oracle.com"  -H  "user-agent: mozilla/5.0  (windows nt  6.3; win64; x64; rv:47.0)  gecko/20100101 firefox/47.0 " -H " Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 " -H " accept-language:  zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 " --compressed -H " referer: http://www.oracle.com/ Technetwork/java/javase/downloads/jdk8-downloads-2133151.html " -H " Cookie: aru_lang=us; s_ Nr=1472257078143; eloqua=guid=e0964a7736384dc98085509e60e04539; s_cc=true; gpw_e24=http "%" 3 A "%" 2F "%" 2fwww.oracle.com "%" 2Ftechnetwork "%" 2Fjava "%" 2Fjavase "%" 2Fdownloads "%" 2fjdk8-downloads-2133151.html;  s_sq= "%" 5B "%" 5BB "%" 5D "%" 5d; oraclelicense=accept-securebackup-cookie " -H " connection:  Keep-alive " 

Live Download

curl  "Http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz? Authparam=1472300350_2a4acf9c53c18478db4839cbf7ec69c6 " -H " host: download.oracle.com " -H   "user-agent: mozilla/5.0  (windows nt 6.3; win64; x64; rv:47.0)   gecko/20100101 firefox/47.0 " -H " accept: text/html,application/xhtml+xml,application/xml;q =0.9,*/*;q=0.8 " -H " accept-language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 " --compressed  -H  "referer: http://www.oracle.com/technetwork/java/javase/downloads/ Jdk8-downloads-2133151.html " -H " cookie: s_nr=1472257078143; eloqua=guid= E0964a7736384dc98085509e60e04539; s_cc=true; gpw_e24=http "%" 3 A "%" 2F "%" 2fwww.oracle.com "%" 2Ftechnetwork "%" 2Fjava "%" 2Fjavase "%" 2Fdownloads "%" 2fjdk8-downloads-2133151.html; s_sq= "%" 5B "%" 5BB "%" 5D "%" 5d; oraclelicense=accept-securebackup-cookie " -H " connection: keep-Alive " 

The real authparam change every time.

Curl can download the file through the-o parameter, or it simply outputs the content to the console.

So the curl mode of the download command is

Curl-l "Http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz"
-H "Cookie:oraclelicense=accept-securebackup-cookie"-H "connection:keep-alive"-O

Where the-l parameter can trace the redirected address, no-L can only return 302 of the results, the useful content of the cookie is the consent agreement that part, connection:keep-alive this sentence to add, otherwise the download speed will become a snail

Execution results are as follows

  1. [Email protected] ~]# curl-l "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz"- H "Cookie:oraclelicense=accept-securebackup-cookie"-H "connection:keep-alive"-O
  2. % total% Received% xferd Average speed Time Time current
  3. Dload Upload Total spent
  4. 8 174M 8 14.1M 0 0 404k 0 0:07:23 0:00:35 0:06:48 463k

The same wget way of downloading commands for, wget benefits can be automatically redirected without us worrying about

wget--no-check-certificate--no-cookies--header "Cookie:oraclelicense=accept-securebackup-cookie"/HTTP/ Download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz

Where--no-check-certificate means that the SSL certificate is not verified, because the middle of the two 302 will access HTTPS, will be related to the issue of certificates, not check can be faster, the impact is not small, another--no-cookies means not to use cookies, Of course, the first time in the header designated will take, the back of the redirect is not brought, this effect is not big, can not add.

  1. [Email protected] downloads]# wget--no-check-certificate--no-cookies--header "cookie:oraclelicense= Accept-securebackup-cookie "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz
  2. --2016-08-27 20:47:52--http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz
  3. Resolving download.oracle.com ... 206.160.170.51, 206.160.170.9
  4. Connecting to download.oracle.com|206.160.170.51|:80 ... Connected.
  5. HTTP request sent, awaiting response ... 302 Moved temporarily
  6. location:https://edelivery.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz [following]
  7. --2016-08-27 20:47:52--https://edelivery.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz
  8. Resolving edelivery.oracle.com ... 60.254.134.143
  9. Connecting to edelivery.oracle.com|60.254.134.143|:443 ... Connected.
  10. HTTP request sent, awaiting response ... 302 Moved temporarily
  11. location:https://edelivery.oracle.com/osdc-otn/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz [ Following]
  12. --2016-08-27 20:47:53--https://edelivery.oracle.com/osdc-otn/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz
  13. Reusing existing connection to edelivery.oracle.com:443.
  14. HTTP request sent, awaiting response ... 302 Moved temporarily
  15. Location:http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz? authparam=1472302193_c5af865490ac9f21f2605a3abee94745 [following]
  16. --2016-08-27 20:47:53--http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-i586.tar.gz? authparam=1472302193_c5af865490ac9f21f2605a3abee94745
  17. Connecting to download.oracle.com|206.160.170.51|:80 ... Connected.
  18. HTTP request sent, awaiting response ... OK
  19. length:183456778 (175M) [Application/x-gzip]
  20. Saving to: "Jdk-8u101-linux-i586.tar.gz.1"
  21. 2% [==>] 4,740,512 863k/s ETA 4m 40s

Reference Link: http://blog.csdn.net/gsls200808/article/details/52336745

wget and Curl Download JDK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.