-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetMaxcoinBlockInfo.py
98 lines (55 loc) · 2 KB
/
GetMaxcoinBlockInfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python
import sys
import time
reload(sys)
sys.setdefaultencoding('utf8')
import urllib2
import json
from twython import Twython, TwythonError
## Setting these as variables will make them easier for future edits
app_key = ''
app_secret = ''
oauth_token = ''
oauth_token_secret = ''
## Prepare your twitter, you will need it for everything
twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
#The above should just be a single line, without the break
import urllib2
import json
import threading
def run_total_id():
threading.Timer(1200, run_total_id).start()
total_id = ('Maxcoin Block Info ' + '@getmaxcoin ' )
url = urllib2.urlopen('http://api.maxcoinhub.io/Blockchain/GetBlockCount')
url = url.read()
j = json.loads(url)
s = j['result']
new = str(s)
newurl = urllib2.urlopen('http://api.maxcoinhub.io/Blockchain/GetMiningInfo')
newurl = newurl.read()
j1 = json.loads(newurl)
hello = j1['result']['difficulty']
new1 = str(hello)
hello1 = j1['result']['networkhashps']
new2 = str(hello1)
newhello = j1['result']['createdOn']
newblock = str(newhello)
blockapi = urllib2.urlopen('http://api.maxcoinhub.io/Blockchain/GetBlockHash/' + new)
blockapi = blockapi.read()
gettingjson = json.loads(blockapi)
results = gettingjson['result']
newcode1 = str(results)
blockcode = urllib2.urlopen('http://api.maxcoinhub.io/Blockchain/GetBlock/' + newcode1)
blockcode = blockcode.read()
blockjson = json.loads(blockcode)
blockresults = blockjson['result']['merkleRoot']
blocktxt = str(blockresults)
blocks = (total_id + '\n' + 'Blocks: ' + new + '\n' + 'Block Hash: ' + newcode1 + '\n' + 'Merkle Root: ' + blocktxt + '\n' + 'Difficulty: ' + new1 + '\n' + 'Block Created On: ' + newblock)
txt1 = str(blocks)
try:
s = twitter.update_status(status=blocks)
except TwythonError, e:
if e.error_code == 403:
pass
print blocks
run_total_id()