我一直在使用以下内容通过脚本下载JDK 8u112。
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz
最近,它会抛出ERROR 404:找不到,当你转到链接时,它会在Downloading Java JDK on Linux via wget is shown license page instead中显示相同的文字
我也试过http://download.oracle.com/otn/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz,但它会抛出401授权错误。
有关于此的新工作吗?
答案 0 :(得分:0)
似乎可以通过wget下载最新版本的jdk,但不能下载档案中的文件。 因此,我使用casper.js脚本登录Oracle并下载。
以下是我下载日文版jdk8u121的脚本。当前脚本将仅尝试下载但在重定向时将失败。我使用download.sh bash脚本扫描日志以获取带有session参数的url并使用wget进行实际下载。
您需要替换< 用户名>和< 密码>使用有效的登录Oracle站点。
更改 jdkTag 和 jdkFileLink 的值以获取您要下载的jdk版本。
oraclejdk.js
var casper = require('casper').create({
verbose: true,
logLevel: 'info', // debug
pageSettings: {
userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36",
loadImages: false,
loadPlugins: false
}
});
// login info
var loginUrl='http://www.oracle.com/webapps/redirect/signon?nexturl=https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html';
var username='<username>';
var password='<password>';
// accept license page info
var jdkUrl='http://www.oracle.com/technetwork/';
var jdkTag='jdk-8u121-oth-JPR';
// download jdk info
var jdkFileLink='jdk-8u121-oth-JPRXXXjdk-8u121-linux-x64.tar.gz';
// open login page
casper.start(loginUrl);
casper.thenEvaluate(function(username, password) {
// this.capture('loginPage.png', {top:0, left:0, width:600, height:800});
document.querySelector("#sso_username").value = username;
document.querySelector("#ssopassword").value = password;
doLogin(document.LoginForm);
}, {
username: username,
password: password
});
// login to oracle site
casper.then(function() {
this.waitForUrl(jdkUrl, function() {
// this.capture('jdkPage.png', {top:0, left:0, width:1200, height:800});
this.evaluate(function(jdkTag) {
disableDownloadAnchors(document, false, jdkTag);
hideAgreementDiv(document, jdkTag);
writeSessionCookie('oraclelicense', 'accept-securebackup-cookie');
}, {
jdkTag: jdkTag
});
}, null, null, 5000);
});
// accept license
casper.then(function() {
this.waitFor(function checkLink() {
return this.evaluate(function(jdkTag) {
return (document.getElementById('agreementDiv' + jdkTag).getAttribute('style') === 'visibility: hidden;');
}, {
jdkTag: jdkTag
});
}, function then() {
// this.capture('acceptedLicense.png', {top:0, left:0, width:1200, height:800});
downlink = this.evaluate(function(jdkFileLink) {
var jdkElement = document.getElementById(jdkFileLink);
if (jdkElement) {
var jdkLink = jdkElement.getAttribute("href");
jdkElement.click();
return jdkLink;
}
}, {
jdkFileLink: jdkFileLink
});
}, null, 5000);
});
casper.run();
download.sh
#!/bin/bash
url=$(casperjs --web-security=no oraclejdk.js |grep "http://download.oracle.com/otn/java/jdk" $() | sed -e 's/^.*: //')
jdk=$(echo "${url}" | sed -e 's/^.*jdk-/jdk/' |sed -e 's/?.*//')
wget -O "${jdk}" "${url}"
答案 1 :(得分:0)
这不是您问题的直接答案...但是,这是我如何获取最新jdk下载URL的URL
#!/bin/bash
jdkwebinstallerDownloadPage="https://www.oracle.com"$(curl -s https://www.oracle.com/technetwork/java/javase/downloads/index.html | unix2dos | grep "<a name=\"JDK8\"" | sed 's/^.*\<a name=\"JDK8\" href=//g' | sed -r 's/>.*//g' | sed s/\"//g)
## Above yields https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
jdkinstallerDownloadURL=$(curl -s $jdkwebinstallerDownloadPage | grep windows | grep downloads | grep x64 | grep jdk | grep -v demos | sed -r 's/^.*https/https/g' | sed -r 's/\".*//g')
## yields https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk-8u221-windows-x64.exe
我现在正在寻找如何使用wget从此URL下载...,因为我具有登录到https://login.oracle.com/mysso/signon.jsp的oracle登录网页的凭据。