-
-
Save narfdotpl/4502171 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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