Advertisement
0xNOP

VOTOPR2016 API SCRAPER-Parse Name & Votes for each Candidate

Oct 26th, 2016
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import urllib, json
  2.  
  3. url = "http://www.votopr2016.com/api"
  4. response = urllib.urlopen(url)
  5. data = json.loads(response.read())
  6.  
  7. candidates = 0
  8. for countme in data["candidates"]:
  9.     candidates = candidates + 1
  10.     print("Nombre: " +  data["candidates"][candidates - 1]["candidate_name"] + "\n" + "Votos: " + data["candidates"][candidates - 1]["candidate_votes"] + "\n------------------------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement