Automate Instagram Messages using PythonIn this article, we will automate the operation of sending Instagram Messages using Python. First of all, let us look at what is Instagram. Instagram is a prominent social media platform that focuses on the photo and video sharing. It's been operating since 2010 and has maintained its appeal by introducing inventive new features like Instagram Stories, shopping, Instagram Reels, and more. Instagram is a picture and video-sharing social networking website created by Kevin Systrom and Mike Krieger in 2010 and later bought by Facebook Inc. Users may upload photographs and videos that can be filtered and grouped using hashtags and geotagging. Posts can be shared with the entire public or only with pre-approved followers. Users may browse other people's content by tag and location, check what's popular, such as photos, and follow other people to add their content to their own personal feed. When the resolution was upgraded to 1080 pixels in 2015, this restriction was removed. It also included texting features, the ability to share multiple photos or videos in a single post, and a Stories feature, similar to Snapchat's, that allowed users to post content in a chronological feed that was accessible by others for 24 hours. As of January 2019, 500 million individuals utilize Stories every day. Instagram, which was bought by Facebook in 2012 and now has over a billion users, has become ingrained in people's lives. Instagram was first defined by the fact that it only allowed the material to be framed in a square (1:1) aspect ratio of 640 pixels, which corresponded to the width of the iPhone at the time. Instagram is a platform that both individuals and businesses may utilize. Companies may use the photo-sharing app to promote their brand and products by creating a free business account. Businesses with business accounts may get free engagement and impression analytics. According to Instagram's website, more than 1 million marketers utilize the platform to share their stories and achieve commercial goals. Furthermore, 60% of users report that the app assists them in discovering new products. Now let us have a look at the code Code: Output: from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 1 Enter the username to login to https://www.instagram.com/ user_name_demo Enter the password to login to https://www.instagram.com/ P@ssw0rd To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to login into the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 2 Enter the number of users to whom you want to send messages to 3 Enter the username of user 1 target_user_1 Enter the username of user 2 target_user_2 Enter the username of user 3 target_user_3 To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 3 Enter the message for the user with username target_user_1 Hi, this is a message for user1. Enter the message for the user with username target_user_2 Hope you get this message. Enter the message for the user with username target_user_3 User3 this message for you. To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 4 Logged In Successfully and navigated to the homepage. To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To login to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 5 [target_user_1] message sent to [Hi this is message for user1.] successfully. [target_user_2] message sent to [Hope you get this message.] successfully. [target_user_3] message sent to [User3 this message for you.] successfully. Messages were sent successfully. To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 2 Enter the number of users to whom you want to send messages to 1 Enter the username of user 1 Ronaldo. Chris To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 3 Enter the message for the user with the username Ronaldo.Chris Hi, I'm a big fan of your game. To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 5 [ronaldo. cris] message sent to [Hi I'm a big fan of your game.] successfully. Messages were sent successfully. To move forward with the code, enter either [y] or [n] to halt y from the listed below the list of operations select any one of the operations: 1. To provide the credentials(username/password) to log in to the website. 2. To provide the list of usernames of the users to whom to send the messages. 3. To provide the list of messages that will be sent to specified users. 4. To log in to the website and navigate to the homepage of the website. 5. To type messages for all the users and send those typed messages. 6. To exit from the code execution. 6 Explanation: In the code which is written above as we can see in the output in the main function is written which has the object created for the above written class, and this created object is used for calling all the different functions which are written in the above class, the sequence of the program goes like this the user is provided with a list of options to select from the user can select any operation from the list the operation which are provided in the list are like to provide the credentials to login to the website, to provide a list of usernames to whom the user wants to send the messages, to provide the list of messages which needs to be sent to those usernames which are provided in the previous steps, after providing all the required input the user can select the login function and navigate to the home page, after the success for authentication and login to the website the user then choose for the option to type and send the message, this option will it will invoke the main function which is written in the our class that will actually perform the operation of typing the message in the respective chat box office username which are provided in the second step and the the corresponding message is typed in the chat work of of that user and then there is a click on the send button to send that message to the target user and this process is repeated for all the user that are present in the list of user name which is provided by the user in the previous steps. Advantages of Automation:
Disadvantages of Automation:
So, in this article, we have understood how to automate the process of sending Instagram messages using python. Next TopicPython SimpleHTTPServer Module |