Instagram Post Using Python

Instagram Post Using Python

In this article, we will see a Python code of Instagram Post Using Python. We will be using a pip module for this project. The code is given below and the explanation clears your doubts about Instagram Automation with Python. We have a Python Automation tutorial with Selenium on our website. Check it out.


Requirements for the simple bot:


For the Instagram Automation with Python code to execute properly, you should have met the following requirements.

Python 2.7 and above or Python 3.4 and above.

The “instabot” module. You can install this module from the following shell script which you can run in Powershell, Terminal, Command Prompt, etc.

pip install instabot

Code


from instabot import Bot
#the main object for python automation
bot = Bot()

bot.login(username="yourUsername", password="yourPassword")

bot.upload_photo("imageFile.jpg", caption="The caption you want.")

Explanation:


  • In coding for “Instagram Post Using Python” first, import the module “instabot” and the class “Bot” from “instabot” which will help us in this python automation bot.
  • Then, set the variable “bot” as the Bot() object.
  • Likewise, with the “bot” object, write the “login” method and send the arguments “username” with your username and “password” with your password. Your data will not be stored by anyone. So, don’t worry about your data being stolen.
  • Lastly, write the upload() method. Then, pass the path to the image file and the caption.

Comment your queries or anything you want to know or tell us based on this post or website.

Tell us if you found something wrong in the post.

Thanks for reading

Keep Coding, Keep Learning


Also Read:



Share:
Avatar of Ankur Gajurel

Author: Ankur Gajurel

I am Ankur from Nepal trying to learn different aspects of Information Technology and Physics. I like building websites and minor projects with Python.

3 thoughts on “Instagram Post Using Python

  1. 2021-01-20 17:39:52,537 – ERROR – Photo Upload failed with the following response:
    2021-01-20 17:39:52,538 – INFO – Photo ‘right.png’ is not uploaded.
    2021-01-20 17:39:52,590 – INFO – Total requests: 31

Comments are closed.