[CentralOH] not as sexy as efloehr's cloud graphing....
Eric Miller
miller.eric.t at gmail.com
Sun Apr 5 06:02:36 CEST 2015
...but, still chuckleworthy I hope.
http://www.reddit.com/r/thebutton/comments/31hk2g/realtime_graph_to_predict_the_ultimate_heat_death/
Please excuse the lazy error handling, lack of comments, and the obvious
need to make functions in at least two places. I was just screwing
around...
from lxml import htmlimport requestsimport timeimport librato
user = 'yourLibratoEmail at gmail.com'
token = 'your_____API____________key'
api = librato.connect(user, token)
while True:
try:
page = requests.get('http://www.reddit.com/r/thebutton')
tree = html.fromstring(page.text)
participants =
tree.xpath('//span[@class="thebutton-participants"]/text()')
numbers = tree.xpath('//span[@class="number"]/text()')
page = requests.get('http://www.reddit.com/about')
tree = html.fromstring(page.text)
dailyStats = tree.xpath('//div[@class="value"]/text()')
pressers = participants[0]
subcribers = numbers[0]
activeViewers = numbers[1]
dailyRedditUsers = dailyStats[4]
pressers = pressers.replace(',', '')
subcribers = subcribers.replace(',', '')
activeViewers = activeViewers.replace(',', '')
dailyRedditUsers = dailyRedditUsers.replace(',', '')
api.submit("pressers", pressers)
api.submit("subcribers", subcribers)
api.submit("activeViewers", activeViewers)
api.submit("dailyRedditUsers", dailyRedditUsers)
print pressers
print subcribers
print activeViewers
print dailyRedditUsers
time.sleep(5)
except:
continue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20150405/7dc249ff/attachment.html>
More information about the CentralOH
mailing list