Created
August 20, 2017 00:46
-
-
Save amscotti/84cb6ae1da8fe767fea6358c9a2bbfc2 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
def realm = URLEncoder.encode("Staghelm") | |
def guild = URLEncoder.encode("Controlled Chaos") | |
def url = "http://www.wowarmory.com/guild-info.xml?r=${realm}&n=${guild}".toURL() | |
def types = [ | |
"1": "Warrior", "2": "Paladin", "3": "Hunter", | |
"4": "Rogue", "5": "Priest", "6": "Death Knight", | |
"7": "Shaman", "8": "Mage", "9": "Warlock", | |
"11": "Druid"].withDefault { key -> "unknown" } | |
url.openConnection().with { | |
setRequestProperty("User-Agent", "Firefox/2.0.0.4") | |
inputStream.withReader('UTF-8') { reader -> | |
def characters = new XmlSlurper().parse(reader) | |
.guildInfo.guild.members.character | |
.findAll { it.@level == '80' } | |
.collect { [name: [email protected](), type: [email protected]()] } | |
def groupedByType = characters.groupBy { it.type } | |
println "Total: ${characters.size()} characters found with level 80" | |
groupedByType.each { type, avatars -> | |
println "\n${avatars.size()} characters of class ${types[type]}" | |
avatars.sort { it.name }.each { avatar -> println "- ${avatar.name}" } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment