-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto_class.py
166 lines (119 loc) · 5.46 KB
/
Auto_class.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from selenium import webdriver
from bs4 import BeautifulSoup as bs
from datetime import datetime as dt
from datetime import timedelta as td
import os
from pynput.keyboard import Controller,Key
con = Controller()
chrome_options_1= webdriver.ChromeOptions()
chrome_options_1.add_argument("user-data-dir=D:\\Anuraj\\selenium profile\\Profile 1")
driver = webdriver.Chrome(options=chrome_options_1)
chrome_options_2= webdriver.ChromeOptions()
chrome_options_2.add_argument("user-data-dir=D:\\Anuraj\\selenium profile\\Meet")
meet = webdriver.Chrome(options=chrome_options_2)
driver.get("https://web.whatsapp.com/")
#path = "//span[contains(text(),'CSE B.Tech 2022 Passout')]"
#path = "//div[@class='_3Tw1q']//span[@class='_1hI5g _1XH7x _1VzZY'][contains(text(),'CSE B.Tech 2022 Passout')]"
'''Choose the Group'''
choose = input("Choose your group , then press any key");
driver.implicitly_wait(20)
#driver.find_element_by_xpath(path).click()
#driver.implicitly_wait(5)
def getlink():
try:
html = driver.page_source
soup = bs(html, 'html.parser')
links = soup.find_all('a')
link = links[len(links) - 1].text
return link
except:
return "No"
def gettime():
now = dt.now()
time = now.strftime("%H:%M")
return time
def addtime(i):
time = dt.now() + td(minutes=i)
time = time.strftime("%H:%M")
return time
def meetClass(link):
meet.get(link)
# WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@class='IYwVEf HotEze uB7U9e nAZzG']//div[@class='oTVIqe BcUQQ']//*[local-name()='svg']"))).click()
# WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@class='IYwVEf HotEze nAZzG']//div[@class='oTVIqe BcUQQ']//*[local-name()='svg'] "))).click()
# WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Ask to join')]"))).click()
meet.implicitly_wait(10)
try:
meet.find_element_by_xpath("/html[1]/body[1]/div[1]/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]").click()
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[1]").click()
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[2]/div[1]/div[1]").click()
meet.find_element_by_xpath("//span[contains(text(),'Ask to join')]").click()
except:
meet.find_element_by_xpath("//div[contains(text(),'Ready to join?')]").click()
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[1]").click()
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[2]/div[1]/div[1]").click()
meet.find_element_by_xpath("//span[contains(text(), 'Join now')]").click()
try:
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[1]").click()
meet.find_element_by_xpath(
"//body/div[@id='yDmH0d']/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[2]/div[1]/div[1]").click()
except:
pass
def meet_close():
try:
data = meet.page_source
soup = bs(data, 'html.parser')
participants = soup.find("span", attrs={'class' :"wnPUne N0PJ8e"}).text
participants = int(participants)
if(participants < 2):
meet.find_element_by_xpath("/html[1]/body[1]/div[1]/c-wiz[1]/div[1]/div[1]/div[8]/div[3]/div[9]/div[2]/div[2]/div[1]/span[1]/span[1]/*[local-name()='svg'][1]").click()
return True
except:
return False
def zoomClass(link):
meet.get(link)
def zoomEnd():
if gettime() == zoomtime:
os.system("TASKKILL /F /IM zoom.exe")
return True
else:
return False
'''VARIABLES'''
checktime = gettime()
if os.path.isfile('class_link.txt'):
with open ('class_link.txt', 'r') as f:
checklink = f.read()
print(checklink)
meet_end = 1
zoomend = 1
while True:
time = gettime()
if time == checktime:
link = getlink()
print(gettime()+" : "+link)
checktime = addtime(1)
if link != checklink and link != 'No':
if "meet.google.com" in link and meet_end == 1:
checklink = link
meet_end = 0
meetClass(link)
if "zoom.us" in link and zoomend == 1:
checklink = link
zoomend = 0
zoomtime = addtime(40)
zoomClass(link)
with open("class_link.txt", "w+") as f:
f.write(checklink)
f.close()
else:
print("No link")
if meet_end == 0:
if meet_close():
meet_end = 1
if zoomend == 0:
if zoomEnd():
zoomend = 1