From 92ac4337c34510b623df82007613131042f8efd4 Mon Sep 17 00:00:00 2001 From: alex danamir Date: Sun, 3 Jan 2021 12:49:08 +0300 Subject: [PATCH] add rasp ekzamenov --- .gitignore | 1 + actions.py | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 26d0710..a4e4b36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea venv __pycache__ +.vscode \ No newline at end of file diff --git a/actions.py b/actions.py index 3c50801..b0bfc58 100644 --- a/actions.py +++ b/actions.py @@ -4,6 +4,9 @@ from proxy import proxyDict from bs4 import BeautifulSoup import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +import logging +from pprint import pprint + def getGroups(returnJson=0): @@ -185,20 +188,24 @@ def getTeachPlan(tp_year, sem_no, teach_id, teach_name): def getGroupId(gp_name): allGp = getGroups() + gp_id = allGp.get(gp_name) - print(gp_id) + return gp_id -def getGrpEkzRasp(gp_name, gp_id): +def getGrpEkzRasp(gp_name): + pprint(gp_name) headers = {'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'} url = "https://tplan.madi.ru/tasks/tableFiller.php" + gp_id = getGroupId(gp_name) + pprint(gp_id) + params = { 'tab': '3', - 'gp_name': gp_name, 'gp_id': gp_id } response = requests.post(url=url, data=params, headers=headers, verify=False) @@ -206,12 +213,13 @@ def getGrpEkzRasp(gp_name, gp_id): table_data = [[cell.text for cell in row()] for row in BeautifulSoup(response.text, 'lxml')("tr")] + #pprint(table_data[7:len(table_data)]) - dictOfWords = {i: table_data[i] for i in range(0, len(table_data))} + dictOfWords = {i-7: table_data[i] for i in range(7, len(table_data))} return (json.dumps(dict(dictOfWords), ensure_ascii=False)) if __name__ == '__main__': - ekz = getGrpEkzRasp('1A1', 7555) - print(ekz) + ekz = getGrpEkzRasp("1а3") + pprint(ekz)