Permalink
Browse files

Added 'party' to table

  • Loading branch information...
1 parent 3f1b40f commit 1917590251f47f1afb0c0e4ec9966ef2d038590e @fiveminuteargument committed May 4, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 election.py
View
@@ -21,19 +21,27 @@
if updated != prev_updated:
print updated
- print " Name | Vote "
- print "---------------------+------"
+ print " Name | Party | Vote "
+ print "---------------------+------------------------------------+------"
table = soup.find("table", {"class" : "candidates"})
for row in table.tbody.findAll("tr"):
- name = row.find("td", {"class" : "candidate"}).contents[0]
+ candidate = row.find("td", {"class" : "candidate"})
+ name = candidate.contents[0]
+
+ party = candidate.find("span", {"class" : "party"}).contents
+ if len(party):
+ party = party[0]
+ else:
+ party = 'Independent'
+
result = row.find("td", {"class" : "result"}).text
- print "%s | %s" % (name.ljust(20), result.rjust(4))
+ print "%s | %s | %s" % (name.ljust(20), party.ljust(34), result.rjust(4))
print "\n"
prev_updated = updated
- sleep(60)
+ sleep(60)

0 comments on commit 1917590

Please sign in to comment.