Created
October 13, 2020 07:13
-
-
Save No-Eul/72efd0972ce7f96146bd32f569097739 to your computer and use it in GitHub Desktop.
Getting HK Level Ranking for JavaScript with MessengerBot R
This file contains hidden or 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
function getHKLevelRank(timeout) { | |
if (timeout === undefined) timeout = 5000; | |
const format = "%-6s %-5s %s\n", | |
rankData = org.jsoup.Jsoup.connect("https://leaderboard.hkdev.services/") | |
.timeout(timeout).get() | |
.getElementsByClass("table table-hover table-condensed").select("tr"); | |
let result = ""; | |
for (let i = 0; i < rankData.size(); i++) { | |
if (i === 0) { | |
let texts = rankData.get(0).select("th").eachText(); | |
result += java.lang.String.format(format, texts.get(1), texts.get(2), texts.get(0)) | |
+ "=============================================\n"; | |
} else { | |
let texts = rankData.get(i).select("td").eachText(); | |
result += java.lang.String.format(format, texts.get(1), texts.get(2), texts.get(0)); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment