Created
May 6, 2019 02:45
-
-
Save Dark1X/b7858d564ad39a1c6b0a77846afd4442 to your computer and use it in GitHub Desktop.
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/env python3 | |
# coding=utf-8 | |
import requests | |
import json | |
import re | |
def getPage(url): | |
response = requests.get(url=url) | |
return response.text | |
if __name__ == '__main__': | |
headers = { | |
'User-Agent':'Mozilla/6.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.84 Safari/537.36', | |
'Accept-Encoding': 'gzip, deflate, sdch', | |
'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6' | |
} | |
pages = ['https://wk588.com/tools/json/kjdbapi.php?n=Bitcoin&dj=0.4&_=1557034433142', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Zcash&dj=0.4&_=1557034433143', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Litecoin&dj=0.4&_=1557034433144', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Dash&dj=0.4&_=1557034433145', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Decred&dj=0.4&_=1557034433146', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Electroneum&dj=0.4&_=1557034433147', | |
'https://wk588.com/tools/json/kjdbapi.php?n=Grin_31&dj=0.4&_=1557034433148', | |
] | |
jsonData = getPage('https://wk588.com/tools/json/qbkuanjiapi.php?n=Bitcoin&dj=0.4&_=1557106802754') | |
#print(json.loads(jsonData)) | |
minerInfoList = json.loads(jsonData)['data'] | |
# 矿机名称列表 | |
nameList = [] | |
# 算力列表 | |
hashRateList = [] | |
# 功耗列表 | |
powerConsumptionList = [] | |
# 能耗比列表 HashPowerConsumptionRatio | |
hpcRatioList = [] | |
# 日产值列表 | |
dailyEarnList = [] | |
# 日电费列表 | |
powerChargeList = [] | |
# 电费占比列表 | |
powerChargeRateList = [] | |
# 每日净收益列表 | |
dailyRetainedProfitList = [] | |
for miner in minerInfoList: | |
if miner['sh'] == 'SHA-256': | |
minerName = re.sub('<\w.*?\s.*?>.*?','',miner['name'],2) | |
nameList.append(minerName) | |
hashRateList.append(miner['kjsn']['xs']) | |
powerConsumptionList.append(miner['kjgh']['xs']) | |
hpcRatioList.append(miner['kjdwgh']['xs']) | |
dailyEarnList.append(miner['rcz']['xs']) | |
powerChargeList.append(miner['rcdf']['xs']) | |
powerChargeRateList.append(str(miner['dfzb']['sz'])+'%') | |
dailyRetainedProfitList.append('¥'+str(miner['rcsy']['sz'])) | |
print(len(nameList)) | |
for i in range(len(nameList)): | |
print('%-20s' % nameList[i] + '\t' + hashRateList[i] + '\t\t' + powerConsumptionList[i] + '\t\t' + dailyEarnList[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment