Created
June 25, 2020 19:53
-
-
Save SeyfSV/a0583f545286b7c2a6964e375f7de6a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RDURL = 'https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/' | |
const https = require('https'); | |
const cheerio = require('cheerio'); | |
var V = 0 | |
var R = 0 | |
var M = 0 | |
var F = 0 | |
const request = https.get(RDURL, | |
(res) => { | |
console.log(res.statusCode); | |
res.on('data', (d) => { | |
console.log(d); | |
var $ = cheerio.load(d); | |
console.log($('html').text()) | |
$('a').each(function(){ | |
var match = $(this).attr('href').match('([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)-IBM-MQC-Redist.*\.gz$') | |
if (match) { | |
if (parseInt(match[1]) == V){ | |
if (parseInt(match[2]) == R){ | |
if (parseInt(match[3]) == M){ | |
if (parseInt(match[1]) > F) { | |
F = match[4] | |
} | |
} | |
else { | |
if (parseInt(match[3]) > M) { | |
M = match[3] | |
F = match[4] | |
} | |
} | |
} | |
else { | |
if (parseInt(match[2]) > R) { | |
R = match[2] | |
M = match[3] | |
F = match[4] | |
} | |
} | |
} | |
else { | |
if (parseInt(match[1]) > V) { | |
V = match[1] | |
R = match[2] | |
M = match[3] | |
F = match[4] | |
} | |
} | |
} | |
}) | |
}) | |
res.on('end', () => { | |
console.log(V, R, M, F) | |
}) | |
} | |
).end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment