Creating a follow a follower script using Python #2 (following)

in #steemit7 years ago

Follow a follower using Python #2.jpg

Hi Steemians,

This follows on from part 1 [link below] where I’m attempting to create a simple script that would list my followers and if I wasn’t following then print the names to the shell and then automatically follow them.
To recap the flow I’m working to is:

  1. Create a list of my follower account names
  2. Create a list of account names of all the people I’m following
  3. Check to see if the follower is on the following list if not:
    a. Print the account name to the shell
    b. Automatically follow the account

So far I have managed to:

  • get steem installed – this took far longer than I expected (due to my incompetence)
  • have successfully got to print to the shell a list of my followers

Oh and to make things even more fun I thought I would do this using a Raspberry Pi 2 as we had one sitting around not doing much!

I have split this into 3.5 parts/posts as it got a bit long for an all in one:
· part 1 getting a list of my followers,
· part 2 getting a list of who I’m following – this post
· part 2.5 not really a part just a bit of code tidying up
· part 3 comparing lists and following

Now I’m doing the same for the list of following. This is pretty much the same as the follower one so I haven’t added as much comment this time

# Import statements
from steem import Steem

# Variables and objects
steem = Steem()
account = 'garethdear'

# Function to count who I'm following
def get_my_following():
    followingCount = steem.get_follow_count(account)['following_count']
    return followingCount

# Get the number I'm following
print("getting my following count")
followingCount = get_my_following()

# Get the list of account names I'm following
print ("Getting my following")
following = []
followingStart = 0
while followingCount > 0:
    tempFollowing = steem.get_following(account, followingStart, 'blog', 100)
    if (followingCount > 100):
        followingStart = tempFollowing[99]['following']
        del tempFollowing[99]
    following.extend(tempFollowing)
    followingCount -=100

myFollowingNameList = []
for aFollower in following:
    name1 = aFollower['following']
    myFollowingNameList.append(name1)

# Print out the names
print("I am following:")
for name in myFollowingNameList:
    print(name)  

Hooray! – Stage 2 complete now onto stage 3 (via 2.5)
I’ll post this in a day or so

Please bear in mind that I am still a newbie to python and there will be many other (and much more elegant) ways of coding this.

Have fun and bye for now
Gareth

Part 1 - https://steemit.com/steem/@garethdear/creating-a-follow-a-follower-script-using-python-1-followers

Sort:  

Beautiful as always. Great job.

Thank you so much for sharing all this information! that's great! All the best! Waiting for more posts! :)

Mass follower making system or bot does not bring a good result in long run.
Most of the system or bots are coded simply.
They do not have any instruction to justify any person or id before follow.

If U are blogging on one or more niche or topics then It is the best way to instruct the bot or software to meet some requirements and then follow if result is positive.
Need some additional conditional statement codes to do.

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.029
BTC 58118.57
ETH 2462.81
USDT 1.00
SBD 2.38