Skip to content

Instantly share code, notes, and snippets.

@narfdotpl
Forked from mstepniowski/results.txt
Last active December 10, 2015 22:28
Show Gist options
  • Save narfdotpl/4502171 to your computer and use it in GitHub Desktop.
Save narfdotpl/4502171 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Requirements: requests, lxml, cssselect
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.cssselect('.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment