Skip to content

Commit 26aa992

Browse files
Merge pull request avinashkranjan#676 from vivek-2000/issue-450
Issue avinashkranjan#450
2 parents 97dddb6 + 969f7f3 commit 26aa992

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

Insta-Bot-Follow-SendMsg/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# instabot.py
2+
## What is the use:
3+
Given a username if the Instagram account is public , will auto-follow and send msg.
4+
Instructions to use:
5+
1. Once we run the program, web driver will start the default browser under automated software (here we use chrome).
6+
7+
2. Then it will ask for the user id of users whom you want to follow and send msg.
8+
9+
3. Then it will ask for the username and password for the account that will be used to follow and send msg.
10+
11+
4. Then it will automatically go to the username of the person whom you want to follow and send msg.
12+
13+
4. After pressing enter, it will automatically open the Instagram account of the user and follow and send msg .
14+
15+
5. Once done, it will Show the Msg.
16+
17+
## Note:
18+
If you are using some other web browser, replace ‘chrome’ by the name of that browser
19+
Modules and tools used:
20+
Selenium, getpass and time
21+
22+
23+
## By Vivek Kumar Patel
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from selenium import webdriver
2+
import time
3+
from webdriver_manager.chrome import ChromeDriverManager
4+
from selenium.webdriver.support.ui import WebDriverWait
5+
from selenium.webdriver.support import expected_conditions as EC
6+
from selenium.webdriver.common.keys import Keys
7+
from selenium.webdriver.common.by import By
8+
from openpyxl import load_workbook
9+
from selenium.webdriver.common.action_chains import ActionChains
10+
11+
browser = webdriver.Chrome(ChromeDriverManager().install())
12+
time.sleep(10)
13+
users=list(map(str,input("Enter Users Username Comma-Separated Whom You Want to Follow and Send Msg ").split(",")))
14+
USERNAME=input("Enter Your Username ")
15+
PASSWORD=input("Enter Your password ")
16+
17+
browser.get('https://www.instagram.com/')
18+
wait = WebDriverWait(browser, 120)
19+
time.sleep(2)
20+
21+
username_field = browser.find_element_by_name('username')
22+
username_field.send_keys(USERNAME)
23+
24+
password_field = browser.find_element_by_name('password')
25+
password_field.send_keys(PASSWORD)
26+
27+
login_btn = browser.find_element_by_css_selector('button[type="submit"]')
28+
login_btn.click()
29+
print(users)
30+
time.sleep(5)
31+
for user in users:
32+
browser.get(f"https://www.instagram.com/{user}/")
33+
time.sleep(3)
34+
try:
35+
follow = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="react-root"]/section/main/div/header/section/div[1]/div[1]/div/div/div/span/span[1]/button')))
36+
follow.click()
37+
time.sleep(3)
38+
except:
39+
pass
40+
try:
41+
message = browser.find_element_by_class_name('_862NM ')
42+
message.click()
43+
time.sleep(4)
44+
browser.find_element_by_class_name('mt3GC').click()
45+
time.sleep(5)
46+
mbox = browser.find_element_by_tag_name('textarea')
47+
mbox.send_keys(input("Write Msg you Want to Send "))
48+
mbox.send_keys(Keys.RETURN)
49+
time.sleep(5)
50+
except:
51+
pass
52+
53+

0 commit comments

Comments
 (0)