forked from HamidMushtaq/steemtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsteemdbtracker.py
More file actions
92 lines (83 loc) · 2.51 KB
/
steemdbtracker.py
File metadata and controls
92 lines (83 loc) · 2.51 KB
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
# Simple bot tracker which uses web crawling of the steemdb site
# Author: Hamid Mushtaq
import time
import sys
import urllib
# Update this value from https://steemnow.com/upvotecalc.html
UPVOTE_VALUE_FOR_TEN_THOUSAND_SP = 2.54
bots = [
"aafrin",
"upmyvote",
"msp-bidbot",
"kittybot",
"boomerang",
"sneaky-ninja",
"voter",
"pushup",
"buildawhale",
"minnowhelper",
"discordia",
"appreciator",
"sleeplesswhale"
]
def getStats(bot):
power = ""
list_of_transfers = []
total_transfered = 0.0
site = "https://steemd.com/@" + bot
f = urllib.urlopen(site)
content = f.read()
lines = content.split("\n")
steem_power = 0
#
#with open(bot + ".txt", "w") as text_file:
# text_file.write(content)
line_ctr = 0
last_line = ""
for line in lines:
if line_ctr > 0:
line_ctr = line_ctr + 1
if ("transfer " in line) and (" SBD" in line) and (bot in line) and (bot not in last_line):
s = line.split()
user_name = last_line.split('>')[-2].split('<')[0]
post_url = line.split('<')[-2].split('>')[-1]
list_of_transfers.append(user_name + ": " + s[1] + " SBD for " + post_url)
total_transfered = total_transfered + float(s[1].strip())
if ("upvote " in line) and (bot in last_line):
line_ctr = 0
#print line
#print "last_line: " + last_line
return steem_power, power, list_of_transfers, total_transfered
if (line_ctr == 0) and ("Voting Weight</h5>" in line) and (steem_power == 0):
line_ctr = 1
if (line_ctr == 3) and (steem_power == 0):
s = line.strip().replace(",", "")
steem_power = int(s)
line_ctr = 0
if (line_ctr == 0) and ("Voting Power</h5>" in line):
line_ctr = 1
if line_ctr == 4:
power = line.strip()
last_line = line
start_time = time.time()
slist = []
for bot in bots:
try:
(steem_power, a, b, c) = getStats(bot)
except:
print "ERROR on reading bot " + bot
pass
power = a.split('%')[0]
element = (bot, steem_power * UPVOTE_VALUE_FOR_TEN_THOUSAND_SP / 1e4, power, b, c)
slist.append(element)
sorted_list = sorted(slist, key=lambda x:float(x[2]))
for stats in sorted_list:
bot_name, bot_worth, power, list_of_transfers, total_transfered = stats
print bot_name + ": " + power + "%",
perc_of_total = str(int(total_transfered * 100 / bot_worth))
print "\t" + str(total_transfered) + "/" + str(bot_worth) + " (" + perc_of_total + " %) SBD transfered"
for t in list_of_transfers:
print "\t" + t
print "\n"
time_in_secs = int(time.time() - start_time)
print "|| Time taken = " + str(time_in_secs / 60) + " mins " + str(time_in_secs % 60) + " secs ||"