All pastes #396375 Raw Edit

Something

public text v1 · immutable
·published 2007-03-15 18:29 UTC
rendered paste body
from urllib2 import urlopen
import sys, time

n = 0
last_measured = time.time()
last_local = 0
last_total = 0
while 1:
    data = urlopen('http://www.fantasycongress.com/fc/public/poll?action=vote&poll=5&answer=20').read()
    counter = int(data.split('_')[-1])
    n += 1
    if n % 5 == 0:
        offset = time.time() - last_measured
        last_measured = time.time()

        local_rate = (float(n) - last_local) / offset
        last_local = n

        total_rate = (float(counter) - last_total) / offset
        last_total = counter

        sys.stderr.write('LOCAL: %d(%.01f/sec)\tTOTAL: %d(%.01f/sec)     \r' % (n, local_rate, counter, total_rate))