Created
October 25, 2019 03:15
-
-
Save jamesmacfie/9fe7c2d33674459aa7e26213f6375b87 to your computer and use it in GitHub Desktop.
Rubbish wee scraper for getting recent Drone build details
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
// Required to `view more`. Let this run for a while. | |
window.setInterval(() => { | |
var b = document.querySelector('.more-button'); | |
if (b) b.click(); | |
})(100); | |
// Now grab the details | |
var builds = document.querySelector('.builds >.build'); | |
var result = Array.from(document.querySelectorAll('.builds > .build')).map((b) => { | |
try { | |
return { | |
buildNumber: b.querySelector('.number').textContent.replace('#', '').replace('.', ''), | |
timeElapsed: b.querySelector('.time-elapsed').textContent.replace('Build duration', '') | |
} | |
} catch (err) { | |
return null | |
} | |
}) | |
// Output | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment