A python class to automate basic instagram operations that can be performed on PC using selenium framework. This bot is not build to 'get 10K follower in one day'.It is a simple bot that will run on your machine.The bots which are in the market usually give more functionalities but they will get banned sooner or later.
- After reading this article ,I try to add some functionalities to the given code in the article.
- Insta Users (specially bots) first follow and then unfollow you after you follow them back, this practice is not an ethical way to gain followers and this is often frustrating.
- This class contains a method analysis that can return a list of these traitors and unfollow them using another method.
- PYTHON
- SELENIUM
-
Follow the link to know how to install python 3.x version ,pip and pipenv in your system if not already installed.
-
Install Firefox in your system if not already installed.
-
Download geckodriver tar.gz file of your system specification from this link.
-
After downloading,extract the tar.gz file using archive manager and move the geckodriver file(not directory) at /usr/local/bin by using command:
sudo mv 'path to the file' 'usr/local/bin
To make it executable
sudo chmod a+x /usr/local/bin/(name of the file)
-
Clone the repository from Harry-kp-patch-1
-
In terminal,move to project directory and create a virtual environment using pipenv and pip install the requirement.txt file.
-
Create a python file in preferablly in the same project folder or you can import the module wherever you want your file to be placed(in other directories just resolve 'module not found error').
-
Write the script and run your file.
instagram.py contain only one class Instagrambot().
bot = Instagrambot('your username,'your password,headless = [Boolean])
headless:- headless depicts how you want your browser to work .If you want a browsing screen as you see in the screenshots do not set its value if not then set it to True.
-
- self.followers:-number of people that follows you.
- self.following = number of people you are following
- self.posts = number of posts
-
-
followUsername :- It takes a username as a input whom you want to follow.
-
unfollowUsername:- It takes a username as a input whom you want to unfollow.
-
followerList:- if a username is provided as an argument ,it will return the list of followers it has otherwise it will return the list of followers of the current login account.
-
followingList:- Same as followerList but returns a list of people you follow.
-
analysis:- It takes two list as an argument followers and following and return three list as traitor,fans and friends.
- traitor:-people you follow but they aren't following you back.
- fans:- people that follows you but you are not following them.
- friends:- people who are maintaining symbiotic relationship.
traitor,fans,friends = bot.analysis(bot.followerList,bot.followingList)
-
isFollowing:- Take username as an argument and returns boolean value if you follow the given account or not.
-
closeBot:- It doesn't take any argument and used at the last of the script to close the bot and return to the terminal.
-
- Method that will download posts from the users timeline.
- Method that will upload the pictures or stories on a regular basis.
- Method that can accept or reject according to followers:following ratio the request if you have a private account.
- Method that can download the bio of users.
Credit goes to Jérôme Mottet for
this article.
This article build the base of the project.