Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 12d7ec3

Browse files
Merge pull request avinashkranjan#948 from nidhivanjare/Instagram-Follow--NotFollow
Instagram follow not follow
2 parents 9888be7 + 5d7c1ec commit 12d7ec3

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

‎Instagram Follow- NotFollow/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Instagram Unfollowers Bot
2+
3+
## Install Chrome Driver
4+
5+
- https://chromedriver.storage.googleapis.com/index.html?path=90.0.4430.24/
6+
7+
## Install Selenium
8+
9+
- pip3 install selenium
10+
11+
## OUTPUT :
12+
13+
<img width="292" alt="Screenshot 2021年04月23日 at 3 20 37 PM" src="https://user-images.githubusercontent.com/55665104/115854117-8ff89b80-a447-11eb-9b2b-8dbb765976a4.png">

‎Instagram Follow- NotFollow/main.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from selenium import webdriver
2+
from time import sleep
3+
import datetime
4+
from prettytable import PrettyTable
5+
6+
start = datetime.datetime.now()
7+
8+
9+
table = PrettyTable()
10+
column_names = ["Non-Followers"]
11+
12+
13+
class InstaBot:
14+
""" for login
15+
"""
16+
17+
def __init__(self, username, pw):
18+
self.driver = webdriver.Chrome()
19+
self.username = username
20+
self.driver.get("https://instagram.com")
21+
sleep(2)
22+
self.driver.find_element_by_xpath(
23+
"//input[@name=\"username\"]").send_keys(username)
24+
self.driver.find_element_by_xpath(
25+
"//input[@name=\"password\"]").send_keys(pw)
26+
self.driver.find_element_by_xpath("//button[@type=\"submit\"]").click()
27+
sleep(4)
28+
self.url = self.driver.current_url
29+
if self.url == "https://www.instagram.com/accounts/onetap/?next=%2F":
30+
self.driver.find_element_by_xpath(
31+
"//button[contains(text(), 'Not Now')]").click()
32+
sleep(4)
33+
self.driver.find_element_by_xpath(
34+
"//button[contains(text(), 'Not Now')]").click()
35+
else:
36+
sleep(2)
37+
self.driver.find_element_by_xpath(
38+
"//button[contains(text(), 'Not Now')]").click()
39+
sleep(1)
40+
41+
def get_unfollowers(self):
42+
""" names of unfollowers
43+
"""
44+
self.driver.find_element_by_xpath(
45+
"//a[contains(@href,'/{}')]".format(self.username)).click()
46+
sleep(2)
47+
self.driver.find_element_by_xpath(
48+
"//a[contains(@href,'/following')]").click()
49+
following = self._get_names()
50+
sleep(2)
51+
self.driver.find_element_by_xpath(
52+
"//a[contains(@href,'/followers')]").click()
53+
sleep(2)
54+
followers = self._get_names()
55+
56+
notfollowingback = [
57+
user for user in following if user not in followers]
58+
59+
table.add_column(column_names[0], notfollowingback)
60+
61+
print(table)
62+
63+
def _get_names(self):
64+
""" names of unfollowers
65+
"""
66+
67+
sleep(2)
68+
scroll_box = self.driver.find_element_by_xpath(
69+
'/html/body/div[5]/div/div/div[2]')
70+
last_ht, ht = 0, 1
71+
72+
# Keep scrolling till you can't go down any further
73+
while last_ht != ht:
74+
last_ht = ht
75+
sleep(1)
76+
ht = self.driver.execute_script(
77+
"""
78+
arguments[0].scrollTo(0, arguments[0].scrollHeight);
79+
return arguments[0].scrollHeight;
80+
""", scroll_box)
81+
82+
# Gets the list of accounts
83+
links = scroll_box.find_elements_by_tag_name('a')
84+
names = [name.text for name in links if name.text != '']
85+
86+
sleep(1)
87+
88+
# Closes the box
89+
close_btn = self.driver.find_element_by_xpath(
90+
'/html/body/div[5]/div/div/div[1]/div/div[2]')
91+
close_btn.click()
92+
93+
return names
94+
95+
96+
usr_name = input("Enter Username : ")
97+
password = input("Enter Password : ")
98+
99+
my_bot = InstaBot(usr_name, password)
100+
my_bot.get_unfollowers()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /