<div dir="ltr">here's a better version.  Switched to statsd/grafana<div><br></div><div><a href="https://www.hostedgraphite.com/7cc81a60/grafana/#dashboard/temp/e6c6a737196e70ca561009cf6bc6abd7b41a4402">https://www.hostedgraphite.com/7cc81a60/grafana/#dashboard/temp/e6c6a737196e70ca561009cf6bc6abd7b41a4402</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 5, 2015 at 8:26 PM, Eric Floehr <span dir="ltr"><<a href="mailto:eric@intellovations.com" target="_blank">eric@intellovations.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Oh that's awesome! And I never would have thought to use something like Librato for this, so double awesome.<br><br></div>But why didn't you tell me I was supposed to wait to press the button? That you could only press it once! :-)<br><br></div>Thanks for sharing that!<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sun, Apr 5, 2015 at 12:02 AM, Eric Miller <span dir="ltr"><<a href="mailto:miller.eric.t@gmail.com" target="_blank">miller.eric.t@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>...but, still chuckleworthy I hope. </div><div><br></div><a href="http://www.reddit.com/r/thebutton/comments/31hk2g/realtime_graph_to_predict_the_ultimate_heat_death/" target="_blank">http://www.reddit.com/r/thebutton/comments/31hk2g/realtime_graph_to_predict_the_ultimate_heat_death/</a><div><br></div><div>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...</div><div><pre style="color:rgb(209,209,209);font-size:medium"><span style="background-color:rgb(0,0,0)"><span style="color:rgb(230,97,112);font-weight:bold">from</span> lxml <span style="color:rgb(230,97,112);font-weight:bold">import</span> html
<span style="color:rgb(230,97,112);font-weight:bold">import</span> requests
<span style="color:rgb(230,97,112);font-weight:bold">import</span> time
<span style="color:rgb(230,97,112);font-weight:bold">import</span> librato

user <span style="color:rgb(210,205,134)">=</span> <span style="color:rgb(0,196,196)">'<a href="mailto:yourLibratoEmail@gmail.com" target="_blank">yourLibratoEmail@gmail.com</a>'</span>
token <span style="color:rgb(210,205,134)">=</span> <span style="color:rgb(0,196,196)">'your_____API____________key'</span>
api <span style="color:rgb(210,205,134)">=</span> librato<span style="color:rgb(210,205,134)">.</span>connect<span style="color:rgb(210,205,134)">(</span>user<span style="color:rgb(210,205,134)">,</span> token<span style="color:rgb(210,205,134)">)</span>

<span style="color:rgb(230,97,112);font-weight:bold">while</span> <span style="color:rgb(227,74,220)">True</span><span style="color:rgb(210,205,134)">:</span>
        <span style="color:rgb(230,97,112);font-weight:bold">try</span><span style="color:rgb(210,205,134)">:</span>
                page <span style="color:rgb(210,205,134)">=</span> requests<span style="color:rgb(210,205,134)">.</span>get<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">'<a href="http://www.reddit.com/r/thebutton" target="_blank">http://www.reddit.com/r/thebutton</a>'</span><span style="color:rgb(210,205,134)">)</span>
                tree <span style="color:rgb(210,205,134)">=</span> html<span style="color:rgb(210,205,134)">.</span>fromstring<span style="color:rgb(210,205,134)">(</span>page<span style="color:rgb(210,205,134)">.</span>text<span style="color:rgb(210,205,134)">)</span>
                participants <span style="color:rgb(210,205,134)">=</span> tree<span style="color:rgb(210,205,134)">.</span>xpath<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">'//span[@class="thebutton-participants"]/text()'</span><span style="color:rgb(210,205,134)">)</span>
                numbers <span style="color:rgb(210,205,134)">=</span> tree<span style="color:rgb(210,205,134)">.</span>xpath<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">'//span[@class="number"]/text()'</span><span style="color:rgb(210,205,134)">)</span>

                page <span style="color:rgb(210,205,134)">=</span> requests<span style="color:rgb(210,205,134)">.</span>get<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">'<a href="http://www.reddit.com/about" target="_blank">http://www.reddit.com/about</a>'</span><span style="color:rgb(210,205,134)">)</span>
                tree <span style="color:rgb(210,205,134)">=</span> html<span style="color:rgb(210,205,134)">.</span>fromstring<span style="color:rgb(210,205,134)">(</span>page<span style="color:rgb(210,205,134)">.</span>text<span style="color:rgb(210,205,134)">)</span>
                dailyStats <span style="color:rgb(210,205,134)">=</span> tree<span style="color:rgb(210,205,134)">.</span>xpath<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">'//div[@class="value"]/text()'</span><span style="color:rgb(210,205,134)">)</span>

                pressers <span style="color:rgb(210,205,134)">=</span> participants<span style="color:rgb(210,205,134)">[</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(210,205,134)">]</span>
                subcribers <span style="color:rgb(210,205,134)">=</span> numbers<span style="color:rgb(210,205,134)">[</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(210,205,134)">]</span>
                activeViewers <span style="color:rgb(210,205,134)">=</span> numbers<span style="color:rgb(210,205,134)">[</span><span style="color:rgb(0,140,0)">1</span><span style="color:rgb(210,205,134)">]</span>
                dailyRedditUsers <span style="color:rgb(210,205,134)">=</span> dailyStats<span style="color:rgb(210,205,134)">[</span><span style="color:rgb(0,140,0)">4</span><span style="color:rgb(210,205,134)">]</span>

                pressers <span style="color:rgb(210,205,134)">=</span> pressers<span style="color:rgb(210,205,134)">.</span>replace<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">','</span><span style="color:rgb(210,205,134)">,</span> <span style="color:rgb(0,196,196)">''</span><span style="color:rgb(210,205,134)">)</span>
                subcribers <span style="color:rgb(210,205,134)">=</span> subcribers<span style="color:rgb(210,205,134)">.</span>replace<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">','</span><span style="color:rgb(210,205,134)">,</span> <span style="color:rgb(0,196,196)">''</span><span style="color:rgb(210,205,134)">)</span>
                activeViewers <span style="color:rgb(210,205,134)">=</span> activeViewers<span style="color:rgb(210,205,134)">.</span>replace<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">','</span><span style="color:rgb(210,205,134)">,</span> <span style="color:rgb(0,196,196)">''</span><span style="color:rgb(210,205,134)">)</span>
                dailyRedditUsers <span style="color:rgb(210,205,134)">=</span> dailyRedditUsers<span style="color:rgb(210,205,134)">.</span>replace<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">','</span><span style="color:rgb(210,205,134)">,</span> <span style="color:rgb(0,196,196)">''</span><span style="color:rgb(210,205,134)">)</span>

                api<span style="color:rgb(210,205,134)">.</span>submit<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">"pressers"</span><span style="color:rgb(210,205,134)">,</span> pressers<span style="color:rgb(210,205,134)">)</span>
                api<span style="color:rgb(210,205,134)">.</span>submit<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">"subcribers"</span><span style="color:rgb(210,205,134)">,</span> subcribers<span style="color:rgb(210,205,134)">)</span>
                api<span style="color:rgb(210,205,134)">.</span>submit<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">"activeViewers"</span><span style="color:rgb(210,205,134)">,</span> activeViewers<span style="color:rgb(210,205,134)">)</span>
                api<span style="color:rgb(210,205,134)">.</span>submit<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,196,196)">"dailyRedditUsers"</span><span style="color:rgb(210,205,134)">,</span> dailyRedditUsers<span style="color:rgb(210,205,134)">)</span>

                <span style="color:rgb(230,97,112);font-weight:bold">print</span> pressers
                <span style="color:rgb(230,97,112);font-weight:bold">print</span> subcribers
                <span style="color:rgb(230,97,112);font-weight:bold">print</span> activeViewers
                <span style="color:rgb(230,97,112);font-weight:bold">print</span> dailyRedditUsers

                time<span style="color:rgb(210,205,134)">.</span>sleep<span style="color:rgb(210,205,134)">(</span><span style="color:rgb(0,140,0)">5</span><span style="color:rgb(210,205,134)">)</span>
        <span style="color:rgb(230,97,112);font-weight:bold">except</span><span style="color:rgb(210,205,134)">:</span>
                <span style="color:rgb(230,97,112);font-weight:bold">continue</span></span></pre></div></div>
<br></div></div>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org" target="_blank">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>