forked from pragnya17/InstaBot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstaBotDemo.py
More file actions
59 lines (51 loc) · 2.62 KB
/
InstaBotDemo.py
File metadata and controls
59 lines (51 loc) · 2.62 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
59
from selenium import webdriver
from time import sleep
# download correct version of chrome driver
# use full path
# pip install selenium in the environment created, make sure to activate the environment (venv not conda)
def open_page():
# 'C:/Users/pragn/PycharmProjects/InstaBot/chromedriver_win32/chromedriver.exe'
driver = webdriver.Chrome('C:/Users/pragn/PycharmProjects/InstaBot/chromedriver_win32/chromedriver.exe') #opens window
return driver
def login(driver):
driver.get("https://instagram.com")
user_name = 'coder__123'
pwd = 'ilovecoding'
sleep(5) #IMPORTANT TO LOAD BEFORE LOGGING IN, could depend on wifi speed
driver.find_element_by_xpath\
('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input').send_keys(user_name)
driver.find_element_by_xpath\
('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[2]/div/label/input').send_keys(pwd)
driver.find_element_by_xpath('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[3]').click()
driver.find_element_by_xpath('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[3]/button/div') \
.click()
def follow(driver, user):
user_page = "https://instagram.com" + user
driver.get(user_page)
sleep(5)
driver.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/div[2]/div/div/div/button')\
.click()
driver = open_page()
login(driver)
sleep(1)
user = "/billnye/"
follow(driver, user)
# user_name = 'coder__123'
# pwd = 'ilovecoding'
# sleep(5) #IMPORTANT TO LOAD BEFORE LOGGING IN, could depend on wifi speed
# driver.find_element_by_xpath('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input')\
# .send_keys(user_name)
# driver.find_element_by_xpath('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[2]/div/label/input')\
# .send_keys(pwd)
# driver.find_element_by_xpath('/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[3]/button/div')\
# .click()
# sleep(3)
# if (driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div/div/button')):
# driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div/div/button').click()
#
# def follow(driver, user):
# user_page = "https://instagram.com" + user
# driver.get(user_page)
# sleep(5)
# driver.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/div[2]/div/div/div/button')\
# .click()