Created
August 2, 2011 12:46
-
-
Save d33tah/1120107 to your computer and use it in GitHub Desktop.
A simple script to calculate avg time needed to find a bitcoin block on Slush's bitcoin mining pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import urllib | |
from lxml import html | |
raw_html = urllib.urlopen("http://mining.bitcoin.cz/stats/").read() | |
parsed_html=html.fromstring(raw_html) | |
#all TRs from the second table, without the header TR | |
data_rows = parsed_html.xpath('//table')[1].xpath('.//tr')[1:] | |
sum_seconds=0 | |
for d in data_rows: | |
#the second column contains the calculation time | |
hr,min,sec=d.xpath('.//td')[2].text_content().split(':') | |
sum_seconds+=int(hr)*3600+int(sec)*60+int(min) | |
tmp_avg = sum_seconds/len(data_rows) | |
print tmp_avg | |
avg_sec=tmp_avg%60 | |
tmp_avg-=avg_sec | |
avg_min=(tmp_avg%3600)/60 | |
tmp_avg-=60*avg_min | |
avg_hr=tmp_avg/3600 | |
print "%02d:%02d:%02d" % (avg_hr, avg_min, avg_sec ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment