<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/">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">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">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">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>