Python script to save and compare active users on steem and hive
Hi there,
Today I had a bit of free time and I spent it in update an old script I publish a while ago on github.
The script used the steem library to operate so it was impossible to use the same commands both for steem and hive, so the necessity to update it.
Now it uses the beem library like all of my scripts and bots ahaha. [very good job indeed ]
The script is very simple, and parse the last hours blocks to detect the users that interact with the blockchain, it clean the list from double and save the list in a file, the process is repeated every hour.
This script allow you to see the hour active, the new ones and the total saved.
from beem import Steem
from beem.blockchain import Blockchain
from beem.nodelist import NodeList
import time
import re
def hour_active(chain):
nodelist = NodeList()
nodelist.update_nodes()
if chain=='steem':
s = Steem(node=nodelist.get_steem_nodes())
else:
s = Steem(node=nodelist.get_hive_nodes())
b=Blockchain(s)
bl_=[]
bl_num=int(b.get_current_block_num())
bl_num_=bl_num-1250
bl=b.blocks(bl_num_,bl_num)
for i in bl:
bl_.append(i['transactions'])
x=('follower','account','voter','from','author')
account=[]
new=[]
for i in x:
acc=re.findall('"'+i+'":"(.+?)"',str(bl_))
for l in acc:
if l not in account:
account.append(l)
if chain=='steem':
file=open('active_acc_steem.txt','r')
old=file.readlines()
file.close()
file=open('active_acc_steem.txt','a')
for i in account:
if i+'\n' not in old:
file.write(str(i)+'\n')
new.append(i)
file.close()
else:
file=open('active_acc_hive.txt','r')
old=file.readlines()
file.close()
file=open('active_acc_hive.txt','a')
for i in account:
if i+'\n' not in old:
file.write(str(i)+'\n')
new.append(i)
file.close()
print ('one hour accounts '+chain,len(account))
print ('one hour brand new '+chain,len(new))
print ('total ACTIVE accounts '+chain,len(old))
counter=1
while True:
print (counter)
try:
hour_active('steem')
hour_active('hive')
except Exception as e:
print (e)
pass
counter+=1
print ('__________________________')
time.sleep(3580)
Here the repo on github:
https://github.com/digital-mine/get_steem_active_users
Here an example output of 1 hour cicle:
Leave Python script to save and compare active users on steem and hive to:
Read more #steem posts
Best Posts From the.journal
We have not curated any of the.journal's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From the.journal
- Restart the A.I. training
- Training new A.I. model
- New track from A.I. generated music
- Difference in output with 2 different A.I. scripts
- New Project- Artificial intelligence Music composer
- New curation trail no delegation required
- Double login (steem/hive) for website
- Python package for steemlogin.com
- How to encrypt information in custom_json [episode 2]
- How to encrypt information in custom_json [episode 1]
- Start to test BLURT blockchain
- Python script to save and compare active users on steem and hive
- delegators list
- steem and hive account creator
- Hive up and HUOBI promotion
- HIVE price UP 130%
- Something is moving [STEEM and HIVE price]
- STEEM-HIVE price and trade 4/8/2020 [VIDEO VERSION]
- STEEM-HIVE price and trade 4/8/2020
- thank you coronavirus helpers google doodle