-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (44 loc) · 2.16 KB
/
main.py
File metadata and controls
52 lines (44 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import time
USERNAME = "YOUR USERNAME"
PASSWORD = "YOUR PASSWORD"
chrome_driver_path = "YOUR CHROMEDRIVER PATH"
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get("https://www.instagram.com/caught_n_posted_8088/")
log_in = WebDriverWait(driver, timeout=60).until(lambda d: d.find_element(By.CSS_SELECTOR, 'a button'))
log_in.click()
time.sleep(10)
username = WebDriverWait(driver, timeout=60).until(lambda d: d.find_element(By.XPATH, '//*[@id="loginForm"]/div/div[1]/div/label/input'))
username.send_keys(USERNAME)
password = driver.find_element(By.XPATH, '//*[@id="loginForm"]/div/div[2]/div/label/input')
password.send_keys(PASSWORD)
time.sleep(2)
enter = driver.find_element(By.XPATH, '//*[@id="loginForm"]/div/div[3]/button')
enter.click()
time.sleep(15)
not_now = WebDriverWait(driver, timeout=30).until(lambda d: d.find_element(By.CSS_SELECTOR, '._ac8f button'))
not_now.click()
time.sleep(10)
followers = WebDriverWait(driver, timeout=60).until(lambda d: d.find_element(By.XPATH, '/html/body/div[1]/div/div/div/div[1]/div/div/div/div[1]/div[2]/div[2]/section/main/div/header/section/ul/li[2]/a'))
followers.click()
buttons = WebDriverWait(driver, timeout=60).until(lambda d: d.find_elements(By.CSS_SELECTOR, 'button._acan._acap._acas'))
time.sleep(5)
count = 0
while True:
for btn in buttons:
try:
driver.execute_script("arguments[0].click();", btn)
count += 1
print(f"{count} buttons clicked")
time.sleep(5)
except:
print("Skipped something")
pass
scr1 = WebDriverWait(driver, timeout=60).until(lambda d: d.find_element(By.XPATH, '/html/body/div[1]/div/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div/div[2]/div/div/div[2]'))
time.sleep(5)
driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", scr1)
print("scrollled")
buttons = WebDriverWait(driver, timeout=60).until(lambda d: d.find_elements(By.CSS_SELECTOR, 'button._acan._acap._acas'))