Hello folks,
I've written a very simple python script, it needs STEEM PYTHON API installed.
The script is an infinite loop that extract all the last hour active users on the STEEM blockchain, and adds them into a file. Every hour it keeps adding users that are not on the file already, and that have done some activity recorded in the blockchain.
The script is very simple, and not "elegant" at all, but I wrote it in 20 minutes, so please be patient about this, I'll try to update it, and get it a bit more "elegant" when I'll get some time, for now it does it job with no issue ;)
here it is:
from steem import Steem
from steem.blockchain import Blockchain
import time
import re
b=Blockchain()
s=Steem()
def hour_active():
bl_num=int(b.get_current_block_num())
bl_num_=bl_num-1250
bl=(str(s.get_blocks_range(bl_num_,bl_num)))
x=('follower','account','voter','from','author')
account=[]
for i in x:
acc=re.findall('"'+i+'":"(.+?)"',str(bl))
for l in acc:
if l not in account:
account.append(l)
file=open('active_acc.txt','r')
old=file.readlines()
file.close()
file=open('active_acc.txt','a')
for i in account:
if i+'\n' not in old:
file.write(str(i)+'\n')
file.close()
print ('one hour accounts',len(account))
print ('total accounts',len(old))
counter=1
while True:
print (counter)
try:
hour_active()
except Exception :
pass
print ('FAILED')
counter+=1
print ('__________________________')
time.sleep(3600)
here my repository on GitHub if you prefer to check it there:
https://github.com/digital-mine/get_steem_active_users
That's all folks
please upvote and follow ;)