forked from ClarityCoders/Instabot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstaBot.py
67 lines (49 loc) · 1.53 KB
/
InstaBot.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
57
58
59
60
61
62
63
64
65
66
67
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def login(browser):
browser.get("https://www.instagram.com/?hl=en")
time.sleep(5)
username = browser.find_element_by_css_selector("[name='username']")
password = browser.find_element_by_css_selector("[name='password']")
login = browser.find_element_by_css_selector("button")
#YOUR USERNAME GOES HERE
username.send_keys("my_username")
#YOUR Password GOES HERE
password.send_keys("mypass291")
login.click()
time.sleep(5)
def Vist_Tag(browser, url):
sleepy_time = 5
browser.get(url)
time.sleep(sleepy_time)
pictures = browser.find_elements_by_css_selector("div[class='_9AhH0']")
image_count = 0
for picture in pictures:
if image_count >= 3:
break
picture.click()
time.sleep(sleepy_time)
heart = browser.find_element_by_css_selector("[aria-label='Like']")
heart.click()
close = browser.find_element_by_css_selector("[aria-label='Close']")
close.click()
image_count += 1
time.sleep(sleepy_time)
def main():
browser = webdriver.Chrome()
login(browser)
tags = [
"programming",
"softwaredeveloper",
"programminglife",
"programmerslife",
"programmerlife",
"developerlife",
"programmers",
]
while True:
for tag in tags:
Vist_Tag(browser, f"https://www.instagram.com/explore/tags/{tag}")
time.sleep(3600)
main()