steem-python experiments #1 - Detect steemians who don't follow you back

in #python8 years ago (edited)

I have been experimenting with the steem-python lately. Not following a steemian who does follow you is totally okay. Not all feelings mutual, I get it.

But for the sake of experiments with the python package (this will be also helpful for new devs to see how things work out on steem package.) let's find out these guys. :)

The steem-python package


It's available on the PYPI. You can just install it by typing

$ [sudo] pip install steem

or if you like 90s:

$ [sudo] easy_install steem

Getting the steem instance


from steem import Steem
s = Steem()

We're all set. Now you're capable of doing a lot of stuff with steem blockchain. By default, Steem class uses default nodes to gather information about the network. If you decide to something time-sensitive or if you need to do send a lot of requests to nodes, you have probably think of setting up your own.

RPC requests to remote nodes are slow. You can bypass it by using it on your own.

Getting the follower list


steem-python also includes some additional classes like Account. This class has some helper functions to get information about the accounts.

You can get an account instance like this:

steem = Steem()
account = Account('emrebeyler', steem)

After this step; getting followers or following list is very easy.

followers = account.get_followers()
following = account.get_following()

This will output a list of string (usernames). Most of the work is done; let's see the diff.

print(set(followings) - set(followers))

This will output with a list of steemians who don't you follow you back. If you want to unfollow these guys, you can just use steem.unfollow() function.

Let's put these together into one script:

from steem import Steem
from steem.account import Account


def users_dont_follow_back(account):
    followers = set(account.get_followers())
    following = set(account.get_following())

    return following - followers


if __name__ == '__main__':
    steem = Steem(
        keys=['<posting_key>']
    )
    account = Account('emrebeyler', steem)
    users = users_dont_follow_back(account)
    print("%s users don't follow you back. Here is the list: \n %s" % (
        len(users), users)
    )

    for user in users:
        print("Unfollowing %s" % user)
        steem.unfollow(user, what=['blog'], account='emrebeyler')
                

Aaaand, action!

Sort:  

Yey! Üstad eline sağlık!
Ne tatlı bir modülmüş böyle ;)

cok guzel bir interface'e sahip. Iyi dusunmusler,

This post received a 54% upvote from @morwhale team thanks to @emrebeyler! For more information, click here! , TeamMorocco! . this is @originalworks . steem @steemprice BTC

GREAT I WILL JOIN YOU SOON, IF I DEPOSIT 0.05 HOW MUCH CAN I GET ?

$5608.89 USD/BTC
Volume: 151301.69 BTC ($848634931.22 USD)
Last Updated Sat Oct 14 00:53:40 2017

The @OriginalWorks bot has determined this post by @emrebeyler to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

To enter this post into the daily RESTEEM contest, upvote this comment! The user with the most upvotes on their @OriginalWorks comment will win!

For more information, Click Here! || Click here to participate in the @OriginalWorks sponsored writing contest(125 SBD in prizes)!!!
Special thanks to @reggaemuffin for being a supporter! Vote him as a witness to help make Steemit a better place!

Thanks for this nice post @emrebeyler I'm looking forward to Your next post

@minnowpond1 has voted on behalf of @minnowpond. If you would like to recieve upvotes from minnowponds team on all your posts, simply FOLLOW @minnowpond.

        To receive an upvote send 0.25 SBD to @minnowpond with your posts url as the memo
        To receive an reSteem send 0.75 SBD to @minnowpond with your posts url as the memo
        To receive an upvote and a reSteem send 1.00SBD to @minnowpond with your posts url as the memo

@reported has voted on behalf of @minnowpond. If you would like to recieve upvotes from minnowponds team on all your posts, simply FOLLOW @minnowpond.

        To receive an upvote send 0.25 SBD to @minnowpond with your posts url as the memo
        To receive an reSteem send 0.75 SBD to @minnowpond with your posts url as the memo
        To receive an upvote and a reSteem send 1.00SBD to @minnowpond with your posts url as the memo

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

Qurator
Your Quality Content Curator
This post has been upvoted and given the stamp of authenticity by @qurator. To join the quality content creators and receive daily upvotes click here for more info.

This post has received a 1.56 % upvote from @drotto thanks to: @banjo.

This wonderful post has received a bellyrub 1.59 % upvote from @bellyrub thanks to this cool cat: @emrebeyler. My pops @zeartul is one of your top steemit witness, if you like my bellyrubs please go vote for him, if you love what he is doing vote for this comment as well.

This post has received a 100.00 % upvote from @upgoater thanks to: @emrebeyler.

This post has received a 4.44 % upvote from @booster thanks to: @emrebeyler.

This post has received a 1.98 % upvote from @boomerang thanks to: @emrebeyler

@boomerang distributes 100% of the SBD and up to 80% of the Curation Rewards to STEEM POWER Delegators. If you want to bid for votes or want to delegate SP please read the @boomerang whitepaper.

This post has received a 25.00 % upvote from @steemdiffuser thanks to: @emrebeyler. Steem on my friend!

Get Upvotes, Join Our Trail, or Delegate Some SP

This post received a 6.19% upvote from @randowhale thanks to @emrebeyler! To learn more, check out @randowhale 101 - Everything You Need to Know!

Calling @originalworks :)
img credz: pixabay.com
Nice, you got a 71.0% @kamikaze upgoat, thanks to @emrebeyler
Want a boost? Minnowbooster's got your back!

If I could turn back !BEER



Hey @emrebeyler, here is a little bit of BEER for you. Enjoy it!