Skip to content

Instantly share code, notes, and snippets.

@grimborg
Forked from mstepniowski/results.txt
Last active December 10, 2015 22:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save grimborg/4503094 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Requirements: requests, lxml
import requests
from lxml import html
TALKNAME = "TITLE OF MY AMAZING TALK (it's a secret!)"
COLOR = '\033[1;34m'
END = '\033[0m'
r = requests.get('http://2013.djangocon.eu/vote/')
document = html.document_fromstring(r.text)
entries = [(int(entry.xpath('div[@class="baloon_counter"]/text()')[0].strip()),
entry.xpath('h4/text()')[0].strip())
for entry in document.xpath('//div[@class="entry"]')]
entries.sort(reverse=True)
for n, entry in enumerate(entries[:25]):
text = u'{:>2}. ({:>4}) {}'.format(n + 1, entry[0], entry[1])
if entry[1] == TALKNAME:
print COLOR + text + END
else:
print text.encode('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment