Skip to content

Instantly share code, notes, and snippets.

@jiansoo
Created February 27, 2019 13:35
Show Gist options
  • Save jiansoo/e80e00ffe6f1d38d8973d3af5651e764 to your computer and use it in GitHub Desktop.
Save jiansoo/e80e00ffe6f1d38d8973d3af5651e764 to your computer and use it in GitHub Desktop.
import urllib.request
import ast
import time
from colorama import Fore, Style
completed = False
# Recieve response from URL
def geturl(url):
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
headers = {'User-Agent': user_agent, }
request = urllib.request.Request(url, None, headers)
response = urllib.request.urlopen(request)
resp = response.read().decode('utf-8')
return resp
# Ethermine API call
def gethdata():
acc = geturl('https://ethermine.org/api/miner_new/007B34B189F91de40D8276e57ece54875Dd14bb9')
liteval = ast.literal_eval(acc)
settings = liteval['settings']
settings = eval(str(settings))
unpaid = liteval['unpaid']
minerStats = liteval['minerStats']
return (settings, unpaid, minerStats)
while True:
try:
# Display Monitoring Results
abc = gethdata()
a = abc[0]
b = (abc[1] / 1000000000000000000)
c = abc[2]
print('''''')
print(Fore.LIGHTGREEN_EX + 'ETH:')
print('''Account:''', a['miner'])
print('''Actual Hashrate:''', round(c['currentHashrate'] / 1000000, 2), '''MH/s''')
print('''Reported Hashrate:''', round(c['reportedHashrate'] / 1000000, 2), '''MH/s''')
print('''Valid Shares:''', c['validShares'])
print('''Invalid Shares:''', c['invalidShares'])
print('''Stale Shares:''', c['staleShares'])
print('''Balance in ETH:''', b)
print(Style.RESET_ALL + '''''''')
time.sleep(120)
except:
# Retry Connection
print('Statistics unavailable! Trying again in a bit!')
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment