Skip to content

Instantly share code, notes, and snippets.

@ZachOrr
Created March 24, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZachOrr/9746697 to your computer and use it in GitHub Desktop.
Save ZachOrr/9746697 to your computer and use it in GitHub Desktop.
import requests
import xmldict
def main():
r = requests.get("http://www.chiefdelphi.com/forums/frcspy.php?xml=2")
matches = xmldict.xml_to_dict(r.content)
upset = 0
total = 0
for match in matches["matches"]["match"]:
if match["typ"] == "P":
continue
foullessRed = int(match["rfin"]) - int(match["rfpts"])
foullessBlue = int(match["bfin"]) - int(match["bfpts"])
if ((int(match["rfin"]) > int(match["bfin"])) and (foullessBlue > foullessRed)) or ((int(match["bfin"]) > int(match["rfin"])) and (foullessRed > foullessBlue)):
upset = upset + 1
total = total + 1
print "Count: ", str(upset)
print "Total: ", str(total)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment