Skip to content

Instantly share code, notes, and snippets.

@No-Eul
Created October 13, 2020 07:13
Show Gist options
  • Save No-Eul/72efd0972ce7f96146bd32f569097739 to your computer and use it in GitHub Desktop.
Save No-Eul/72efd0972ce7f96146bd32f569097739 to your computer and use it in GitHub Desktop.
Getting HK Level Ranking for JavaScript with MessengerBot R
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