Send message on instagram using python

Send message on instagram using python DEFAULT

Instagram Direct Message Bot

Send direct and group message with Instagram bot. Work with Python 3.7.2 and Selenium.

Example :

frominstadmimportInstaDMif__name__=='__main__': # Auto logininsta=InstaDM(username='your_username', password='your_password', headless=False) # Send messageinsta.sendMessage(user='username_target', message='Hey !') # Send messageinsta.sendGroupMessage(users=['user1', 'user2'], message='Hey !')

Work's with InstaPY

Use param on constructor:

frominstadmimportInstaDMif__name__=='__main__': # Auto logininsta=InstaDM( username='your_username', password='your_password', headless=False, instapy_workspace='workspace/' )

InstaDM create table if not exists.

CREATETABLE "message" ( "username"TEXTNOT NULL UNIQUE, "message"TEXT DEFAULT NULL, "sent_message_at"TIMESTAMP );

Work's with InstaPY Dashboard

InstaDM works with an modified version of InstaPy Dashboard.

InstaPy Dashboard is an Open Source project developed by @converge to visualize Instagram accounts progress and real-time InstaPy logs on the browser.

Support

paypal.me/camtosh Buy me a
Sours: https://github.com/CamTosh/instagram-bot-dm

Automate Instagram Messages using Python

In this article, we will see how to send a single message to any number of people. We just have to provide a list of users. We will use selenium for this task.

Packages needed

  • Selenium: It is an open-source tool that automates web browsers. It provides a single interface that lets you write test scripts in programming languages like Ruby, Java, NodeJS, PHP, Perl, Python, and C#, among others. I personally prefer Python as it’s very easy to write code in python. A browser-driver then executes these scripts on a browser-instance on your device. To install this module run this command into your terminal.
pip install selenium
  • webdriver-manager: It provides a way to automatically manage drivers for different browsers. To install this module run this command into your terminal.
pip install webdriver-manager
  • ChromeDriver: ChromeDriver is a separate executable that Selenium WebDriver uses to control Chrome.
  • Google Chrome
     

Step 1: Importing all the necessary libraries.

Python3

Step 2: Using chrome with this code will always work (no need to worry about updating chromedriver version)

Python3



Step 3: Before declaring a Class we will make a list of users( any no. of users in this code I am using three users.) in that list you have to send the username of the person you want to send a message to and the message we want to send to all the users.

Python3

Step 4: Here I am creating a class function all the code will be written inside this class so, In the end, we just have to just call this class. Let’s create an __init__ function that can be called when an object is created from the class,__init__ will provide the access that is required to initialize the attributes of the class.

Python3

 
 
 
 
 
 
 

Step 5: Creating a Login function where all the steps will be written

Python3

 
 

Note: for finding the XPath right-click on the element then you see the inspect option on a web browser.

Selecting xpath

Step 6: HANDLING POP-UP BOXES –  When you log in to Instagram you will come across two pop-up boxes as shown in the images. The first one will be asking about do you want to save info or not it will click on not now. The second one will be asking you to turn off the notifications or not so we will again click on not now as shown in the given code.



Python3

1st pop-up box

2nd pop-up  box

Step 7: Clicking on the message option on the right corner 

Message button(Direct button)

Note: This will click on the message(direct) option.

Python3

Step 8: Clicking on the pencil option here we type the user’s name.

Python3

Step 9: Here is the main part of the code where we take a username from the list search for it and message that person. This process is in the loop to take username.

Python3

Step 10: We have finally completed the code. It’s time to create a function where we will pass the username and the password of the account in which we want to login and call our class here.

Python3

Step 11: Let’s call our function

Python3

Let’s put all the code together

Python3




My Personal Notesarrow_drop_up
Sours: https://www.geeksforgeeks.org/automate-instagram-messages-using-python/
  1. Kenworth dealership georgia
  2. Jbr vineyards
  3. Large retro fridge
  4. Settings shortcut iphone

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.

Requirements:

  1. Chrome Driver for Chrome Browser (https://chromedriver.chromium.org/) or Gecko Driver for Firefox(https://github.com/mozilla/geckodriver/releases)
  2. 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 

 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

Approach:

Step 1: Importing modules and entering the login information along with the username of the user whom you want to send a message.

Python3

 
 

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.

 

Python3

 

 
 

Step 3: Function to enter the URL of the page

 

Python3

Step 4: Function to login to Instagram  

Python3

 
 
 
 

 
 

Step 5: Find the message Button on the User profile page and then send random messages to the user

 

Python3

 
 

Step 6: Calling Functions

 

Python3

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.

Output:




My Personal Notesarrow_drop_up
Sours: https://www.geeksforgeeks.org/send-direct-message-on-instagram-using-selenium-in-python/
Instagram Bot To Send message who liked your posts Using Python - Python Programming

victorcarrico/spread_instagram_message.py

fromInstagramAPIimportInstagramdefget_user_info_and_login():try:username=raw_input('Your Instagram username:\n')password=raw_input('Your Instagram password:\n')print'Wait a second, logging in your account.\n'api=Instagram(username, password)api.login()print'Your are logged in.\n'except:print'Login has failed, please try again.'get_user_info_and_login()returnapidefmain():api=get_user_info_and_login()recipients=raw_input('Write the usernames of the recipients separating by comma (Ex: bruna,victor,chico)\n')message=raw_input('Write the message:\n')recipients_list=recipients.split(',')recipients_ids_list= []forrecipientinrecipients_list:user_info=api.searchUsername(recipient)recipient_id=user_info.getUsernameId()recipients_ids_list.append(str(recipient_id))print('Sending the message...\n')try:api.direct_message(recipients_ids_list, message)except:print'Failed :( Please try again.\n'else:print'Your message was successful sent! :D\n'if__name__=='__main__':main()
Sours: https://gist.github.com/victorcarrico/62689d6dd0c2c67350f20969cbb88afe

Message using python send on instagram

.

Send bulk messages to Instagram users - Python Selenium library to send message automatically-Part 1

.

Now discussing:

.



559 560 561 562 563