This repository has been archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
get_follow_req.py
56 lines (41 loc) · 1.52 KB
/
get_follow_req.py
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
53
54
55
56
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import time
import loginInfo
import os
options = webdriver.ChromeOptions()
options.add_argument("--window-size=1920x1080")
options.add_argument("--incognito")
chromedriver_path = './chromedriver'
f = open("follow_req.txt","w")
s=Service('./chromedriver.exe')
browser = webdriver.Chrome(service=s, options=options)
browser.get("https://www.instagram.com/")
time.sleep(3) #Waiting 3 seconds after we open the page.
#IG Login -->
username=browser.find_element(By.NAME, "username")
username.send_keys (loginInfo.username)
password =browser.find_element(By.NAME, "password")
password.send_keys(loginInfo.password)
login_button = browser.find_element(By.XPATH, "//button[@type='submit']")
login_button.click()
time.sleep(6)
browser.get("https://www.instagram.com/accounts/access_tool/current_follow_requests")
while True:
try:
vm_button = browser.find_element(By.XPATH, '//*[@id="react-root"]/section/main/div/article/main/button')
vm_button.click()
time.sleep(2)
except NoSuchElementException:
break
cfreq_source = browser.find_elements(By.XPATH, "//div[@class='-utLf']")
count=0
for x in cfreq_source:
f.write(x.text+"\n")
count+=1
f.close()
print("Got "+str(count)+" users you have sent follow request in \"follow_req.txt\" file, now exiting browser...")
browser.quit()
os.system('python cancel_req.py')