Send Direct Message On Instagram using Selenium in Python
In this article, we will learn how we can send a direct message to users on Instagram without any manual action. We will be using the selenium module to do this task.
- Chrome Driver for Chrome Browser (https://chromedriver.chromium.org/) or Gecko Driver for Firefox(https://github.com/mozilla/geckodriver/releases)
- Selenium Package. To install this type the below command in the terminal.
pip install selenium
Note: For more information, refer How to install Selenium in Python
Step 1: Importing modules and entering the login information along with the username of the user whom you want to send a message.
Step 2: Function to initialize Firefox or chrome session. You might need to add the path to the web driver. Chrome function, it depends on your installation.
Step 3: Function to enter the URL of the page
Step 4: Function to login to Instagram
Step 5: Find the message Button on the User profile page and then send random messages to the user
Step 6: Calling Functions
That’s it! This script will automatically send messages to your loved one. You can do a lot by modifying this script like scheduling automatic messages, sending messages to bulk users and many more.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course