Check your followers with steem-python

jjb777(56)
Published in
#steem
Words
377
Reading
2 min
Listen
Play
9y

Hi steemit friends.

I recently found the steem-python library and wanted to experiment a little bit with it. I wrote a simple script that lists all my followers and writes a simple .html file as a result.

The result

When executing the script, a .html file is generated with a timestamp in the current folder. So you could execute the script multiple times (e.g. each week) and compare the result files. The result file lists all the followers in a table with the following attributes: Account Name, Steem Power, Voting Power. The account names are directly linked, so you can click on the name and in a new tab the account opens on the steemit website.

The code

Basically it all start with the creation of a steem object:

s = Steem()

I introduced a dictionary to not load an account multiple times:

dict = {} # dictionary to tmp store accounts


def get_account_from_map(account):
 a = dict.get(account, '')
 if a == '':
   a = s.get_account(account)
   dict[account] = a
 return a

I defined some helper methods to get the sp and vp in printable format (note: i added rounding)
def get_sp(account):
 a = get_account_from_map(account)
 return round(Converter().vests_to_sp(int(a['vesting_shares'].split('.')[0])))

def get_vp(account):
 a = get_account_from_map(account)
 return '{0:.2f}%'.format(int(a['voting_power'])/100)

And finally loop over the followers and write a .html file (note: i simplified the code a bit for better readability):
followers = s.get_followers('jjb777', '', 'blog', 1000)
file = open('file_name', 'w')
file.write('')

for follower in followers:
 name = follower['follower']
 file.write('<tr><td><a href="https://steemit.com/@{}">{}</a></td><td>{}</td><td>{}</td></tr>'.format(name, name, get_sp(name), get_vp(name)))

file.write('</table></body></html>')
file.close()


The full script is on my github account: followers_html.py

The preconditions
- To run this code you need python3 and steem-python installed
- Adapt the constants (ACCOUNT_NAME, FOLLOWER_LIMIT) before you run the script yourself

The Conclusion
what have I learned from all this?
- I made my first steps with python and steem-python
- Analysing the output of my script:
- I have only one follower with more than 10K SP, thanks libertyteeth@libertyteeth
- From my 223 followers there are 13 above 1K SP.

What's next?
I'm eager to try out more functionality of the steem-python library. Maybe I will write more posts about it.
If you have suggestions please leave a comment.

In the end it was all fun to me. If you like this post please upvote or leave a comment. 

Thanks. J

Check your followers with steem-python | Ecency