Skip to content

Automate certain actiivties on Instagram i.e. sending direct messages

Notifications You must be signed in to change notification settings

11AnJo/instagram_dm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 

Repository files navigation

Instagram Direct Message Bot

This script provides a way to automate sending direct messages on Instagram.

Support for chrome profiles with automatic logging in.

Dependencies (for python 3.11)

To use this script, you need to have the following Python packages installed:

undetected_chromedriver
selenium
requests
pyotp

You can install them using the following command:

pip3 install selenium pyotp undetected_chromedriver requests

Basic usage

Import the User class from the script:

from instagram_web import User

Create an instance of the User class:

Basic Example (with Chrome profile and credentials):

user = User(
    profile_name="myprofile",
    username="my_instagram_username",
    password="my_instagram_password"
)

Using Two-Factor Authentication (2FA):

user = User(
    username="my_instagram_username",
    password="my_instagram_password",
    token="my_totp_token"
)

Running in Headless Mode:

user = User(
    username="my_instagram_username",
    password="my_instagram_password",
    headless=True
)

Using a non auth Proxy:

user = User(
    username="my_instagram_username",
    password="my_instagram_password",
    proxy="http://proxyserver:port"
)

Custom Chrome and ChromeDriver Paths:

user = User(
    browser_executable_path="/path/to/chrome",
    driver_executable_path="/path/to/chromedriver"
)

Send a direct message to another user:

user.send_msg(to_username="recipient_username", msg="Your message here", skip_if_already_messaged=False)

Send a direct message to another user knowing msg_id:

user.send_msg_to_msg_id(msg_id="recipient_msg_id", msg="Your message here",skip_if_already_messaged=False)

Get session cookies

cookies = user.get_cookies(close_after=False)

Exit driver

user.exit_driver()

Notes

If you have any questions or feedback feel free to contact me.

Caution

This script is provided for educational purposes only. Automating actions on Instagram may violate their terms of service, and your account may be subject to restrictions or bans. Use this script at your own risk.

About

Automate certain actiivties on Instagram i.e. sending direct messages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages