Skip to content

Commit 40e7cc6

Browse files
Add files via upload
1 parent b7f8e4f commit 40e7cc6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

22 - Insta Follower Bot/main.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.keys import Keys
3+
from selenium.common.exceptions import ElementClickInterceptedException
4+
import time
5+
6+
CHROME_DRIVER_PATH = chrome_driver_path = "/Users/fahadsmacbook/Downloads/Python 100 Days/Development/chromedriver"
7+
SIMILAR_ACCOUNT = "thatcodingyogi"
8+
USERNAME = "tashruvatash@gmail.com"
9+
PASSWORD = "0821221221"
10+
11+
12+
class InstaFollower:
13+
14+
def __init__(self, path):
15+
self.driver = webdriver.Chrome(executable_path=path)
16+
17+
def login(self):
18+
self.driver.get("https://www.instagram.com/accounts/login/")
19+
time.sleep(5)
20+
21+
username = self.driver.find_element_by_name("username")
22+
password = self.driver.find_element_by_name("password")
23+
24+
username.send_keys(USERNAME)
25+
password.send_keys(PASSWORD)
26+
27+
time.sleep(2)
28+
password.send_keys(Keys.ENTER)
29+
30+
def find_followers(self):
31+
time.sleep(5)
32+
self.driver.get(f"https://www.instagram.com/{SIMILAR_ACCOUNT}")
33+
34+
time.sleep(4)
35+
followers = self.driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/header/section/ul/li[2]/a')
36+
followers.click()
37+
38+
time.sleep(2)
39+
modal = self.driver.find_element_by_xpath('/html/body/div[4]/div/div/div[2]')
40+
for i in range(10):
41+
self.driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", modal)
42+
time.sleep(2)
43+
44+
def follow(self):
45+
all_buttons = self.driver.find_elements_by_css_selector("li button")
46+
for button in all_buttons:
47+
try:
48+
button.click()
49+
time.sleep(1)
50+
except ElementClickInterceptedException:
51+
cancel_button = self.driver.find_element_by_xpath('/html/body/div[5]/div/div/div/div[3]/button[2]')
52+
cancel_button.click()
53+
54+
55+
bot = InstaFollower(CHROME_DRIVER_PATH)
56+
bot.login()
57+
bot.find_followers()
58+
bot.follow()

0 commit comments

Comments
 (0)