-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (46 loc) · 1.96 KB
/
main.py
File metadata and controls
58 lines (46 loc) · 1.96 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
53
54
55
56
57
58
'''On Windows
Run shell as Administrator.
> Get-ExecutionPolicy
> Set-ExecutionPolicy remoteSigned
Done.
To Undo
> Set-ExecutionPolicy restricted
'''
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support import ui
from selenium.webdriver.common.by import By
f = open("password.txt", "r")
pw = f.read()
f.close()
class InstaBot:
def __init__(self, username, password):
self.username = username
self.driver = webdriver.Chrome('chromedriver.exe')
#Go to instagram
self.driver.get('https://www.instagram.com/accounts/login/?hl=en')
sleep(1)
#Get username
self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[2]/div/label/input').send_keys(username)
#Get password
self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[3]/div/label/input').send_keys(password)
#Login
# self.driver.find_element_by_xpath('//button[@type="submit"]').click()
# sleep(5)
self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[3]/div/label/input').send_keys(Keys.ENTER)
#NOT NOW
notNowButton = WebDriverWait(self.driver, 15).until(
lambda d: d.find_element_by_xpath('//button[text()="Not Now"]'))
notNowButton .click()
sleep(2)
def get_unfollowers(self):
#click on username
self.driver.find_element_by_xpath("//a[contains(@href,'/{}')]".format(self.username))\
.click()
my_bot = InstaBot("chelo_jimenez22", pw)
my_bot.get_unfollowers()