-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_meetings.py
103 lines (88 loc) · 3.93 KB
/
get_meetings.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
import requests
from html.parser import HTMLParser
import sys
import json
import re
import datetime
from urllib3.exceptions import InsecureRequestWarning
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
now = datetime.datetime.now()
proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"}
headers = {
"Host":"portal.tedankara.k12.tr",
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language":"en-US,en;q=0.5",
"Accept-Encoding":"gzip, deflate",
"Content-Type":"application/x-www-form-urlencoded",
"Origin":"https://portal.tedankara.k12.tr",
"Connection":"close",
"Referer":"https://portal.tedankara.k12.tr/login",
"DNT":"1"
}
class JDParser(HTMLParser):
def handle_starttag(self, tag, attrs):
self.attributes = {}
for attr in attrs:
self.attributes[attr[0]] = attr[1]
def get_meetings(uname, passwd):
url = "https://portal.tedankara.k12.tr/login"
r = requests.get(url,verify=False)
cookies = r.cookies
content = r.content
lines = content.splitlines()
line = list(filter(lambda x: b'_token' in x, lines))[0].decode("utf-8")
parser = JDParser()
parser.feed(line)
parser.feed(line)
parser.close()
_token = parser.attributes["content"]
data = "_token={}&kimlikno={}&sifre={}".format(_token,uname,passwd)
r = requests.post(url,data=data,cookies=cookies,headers=headers,verify=False)
cookies = r.cookies
r = requests.get("https://portal.tedankara.k12.tr/veli/zoom",cookies=cookies,verify=False, headers=headers)
content = r.json()
data = {"current_day": content["current_day"],
"current_class": content["current_class"],
"current_student": content["current_student"]}
headers2 = {"Host":"portal.tedankara.k12.tr",
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"Accept":"application/json, text/plain, */*",
"Accept-Language":"en-US,en;q=0.5",
"Accept-Encoding":"gzip, deflate",
"X-Requested-With":"XMLHttpRequest",
"Content-Type":"application/json;charset=utf-8",
"Origin":"https://portal.tedankara.k12.tr",
"Connection":"close",
"Referer":"https://portal.tedankara.k12.tr/",
"DNT":"1"}
headers2["X-XSRF-TOKEN"] = r.cookies["XSRF-TOKEN"]
headers2["X-CSRF-TOKEN"] = _token
r = requests.post("https://portal.tedankara.k12.tr/veli/zoom",cookies=r.cookies,verify=False, json=data, headers=headers2)
classes = r.json()
meetings = []
for i in classes["meetings"]:
data = "_token={}&student={}&id={}".format(_token, content["students"][0],i["meeting_id"])
r = requests.post("https://portal.tedankara.k12.tr/veli/yoklama",allow_redirects=False, cookies=cookies,verify=False, data=data, headers=headers)
data = r.content.decode()
if "Location" not in data:
continue
for j in data.split("\n"):
items = j.split(" ")
if items[0] == "Location:":
invitation = items[-1]
try:
m = re.compile("https:\/\/zoom\.us\/j\/([0-9]*)\?.*pwd=([^#]*)")
g = m.search(invitation)
meeting_url = f"zoommtg://zoom.us/join?confno={g.group(1)}&zc=0&browser=chrome&pwd={g.group(2)}"
http_url = f"https://zoom.us/j/{g.group(1)}?pwd={g.group(2)}"
meetings.append({"meeting_url": meeting_url,
"class": i["topic"],
"time":i["meeting_time"],
"http_url":http_url})
except Exception as e:
print(e)
return meetings