-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstaPA.py
77 lines (54 loc) · 1.8 KB
/
InstaPA.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
68
69
70
71
72
73
74
75
76
import eel
import time
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome("chromedriver.exe")
actions = ActionChains(driver)
eel.init('web')
#https://www.instagram.com/explore/tags/<tagname>/
@eel.expose
def login(uname,pwd):
driver.get("https://www.instagram.com/")
actions = ActionChains(driver)
driver.implicitly_wait(300)
username = driver.find_element_by_name('username')
password = driver.find_element_by_name('password')
if pwd != None or username != None:
username.send_keys(uname)
password.send_keys(pwd)
password.send_keys(Keys.RETURN)
#If the person logs in then the fuction carries out that does like comment wala purpose
@eel.expose
def MainProcess(hashtags,comments,no_of_likes):
no_of_likes = int(no_of_likes)
for tag in hashtags:
url = 'https://www.instagram.com/explore/tags/'+ tag
driver.get(url)
time.sleep(5)
#Clicks on The first Photo
pic = driver.find_element_by_class_name("_9AhH0")
pic.click()
for i in range(no_of_likes + 1):
time.sleep(10)
#Likes the photo
like = driver.find_element_by_class_name("_9AhH0")
like.click()
like.click()
time.sleep(random.randint(2,5))
# Writes a comment
if comments != None:
driver.find_element_by_class_name('Ypffh').click()
comment = random.choice(comments)
driver.find_element_by_class_name('Ypffh').send_keys(comment)
driver.find_element_by_class_name('Ypffh').send_keys(Keys.RETURN)
#next photo
for i in range(random.randint(1,8)):
time.sleep(random.randint(1,4))
actions.send_keys(Keys.RIGHT)
actions.perform()
eel.expose
def terminate():
driver.close()
eel.start('main.html', port=8080, size=(1000,600),host= '127.0.0.1',)