[CentralOH] not as sexy as efloehr's cloud graphing....

Eric Floehr eric at intellovations.com
Mon Apr 6 02:26:45 CEST 2015


Oh that's awesome! And I never would have thought to use something like
Librato for this, so double awesome.

But why didn't you tell me I was supposed to wait to press the button? That
you could only press it once! :-)

Thanks for sharing that!

On Sun, Apr 5, 2015 at 12:02 AM, Eric Miller <miller.eric.t at gmail.com>
wrote:

> ...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
>
>
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20150405/2696224a/attachment.html>


More information about the CentralOH mailing list