bugfix
This commit is contained in:
194
actions.py
Normal file
194
actions.py
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from proxy import proxyDict
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def getGroups(returnJson=0):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
url = "http://tplan.madi.ru/tasks/task3,7_fastview.php"
|
||||||
|
|
||||||
|
response = requests.get(url=url, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.content, 'lxml')
|
||||||
|
|
||||||
|
groups = {}
|
||||||
|
for td in soup.findAll("ul"):
|
||||||
|
for a in td.findAll("li"):
|
||||||
|
groups[a.text.lower()] = a['value']
|
||||||
|
|
||||||
|
if returnJson:
|
||||||
|
return json.dumps(groups, ensure_ascii=False)
|
||||||
|
return groups
|
||||||
|
|
||||||
|
def getGroupsList(returnJson=0):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/task3,7_fastview.php"
|
||||||
|
|
||||||
|
response = requests.get(url=url, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.content, 'lxml')
|
||||||
|
|
||||||
|
groups = {}
|
||||||
|
for td in soup.findAll("ul"):
|
||||||
|
for a in td.findAll("li"):
|
||||||
|
groups[a.text.lower()] = a.text.lower()
|
||||||
|
|
||||||
|
if returnJson:
|
||||||
|
return json.dumps(groups, ensure_ascii=False)
|
||||||
|
|
||||||
|
return (groups)
|
||||||
|
|
||||||
|
def getDepart(returnJson=0):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/task11_kafview.php"
|
||||||
|
|
||||||
|
response = requests.get(url=url, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.content, 'lxml')
|
||||||
|
|
||||||
|
departaments = {}
|
||||||
|
for td in soup.findAll('tr'):
|
||||||
|
for t in td.findAll('td'):
|
||||||
|
for a in t.findAll('option'):
|
||||||
|
departaments[a.text.lower()] = a['value']
|
||||||
|
|
||||||
|
if returnJson:
|
||||||
|
return json.dumps(departaments, ensure_ascii=False)
|
||||||
|
|
||||||
|
return (departaments)
|
||||||
|
|
||||||
|
def getTeach(returnJson=0):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/task8_prepview.php"
|
||||||
|
|
||||||
|
response = requests.get(url=url, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.content, 'lxml')
|
||||||
|
|
||||||
|
teaches = {}
|
||||||
|
for td in soup.findAll('tr'):
|
||||||
|
for t in td.findAll('td'):
|
||||||
|
for a in t.findAll('option'):
|
||||||
|
teaches[a.text.lower()] = a['value']
|
||||||
|
|
||||||
|
if returnJson:
|
||||||
|
return json.dumps(teaches, ensure_ascii=False)
|
||||||
|
|
||||||
|
return (teaches)
|
||||||
|
|
||||||
|
def getFastPlan(gp_name, gp_id):
|
||||||
|
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"
|
||||||
|
params = {
|
||||||
|
'tab': '7',
|
||||||
|
'gp_id': gp_id}
|
||||||
|
response = requests.post(url=url, data=params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
table_data = [[cell.text for cell in row()]
|
||||||
|
for row in BeautifulSoup(response.text, 'lxml')("tr")]
|
||||||
|
|
||||||
|
dictOfWords = {i: table_data[i] for i in range(0, len(table_data))}
|
||||||
|
|
||||||
|
return (json.dumps(dict(dictOfWords), ensure_ascii=False))
|
||||||
|
|
||||||
|
def getExtPlan(gp_name, gp_id, sem_no, tp_year):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '7',
|
||||||
|
'gp_name': gp_name,
|
||||||
|
'gp_id': gp_id,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'tp_year': tp_year}
|
||||||
|
response = requests.post(url=url, data=params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
table_data = [[cell.text for cell in row()]
|
||||||
|
for row in BeautifulSoup(response.text, 'lxml')("tr")]
|
||||||
|
|
||||||
|
dictOfWords = {i: table_data[i] for i in range(0, len(table_data))}
|
||||||
|
|
||||||
|
return (json.dumps(dict(dictOfWords), ensure_ascii=False))
|
||||||
|
|
||||||
|
def getDeptPlan(dep_name, dep_id, sem_no, tp_year):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '11',
|
||||||
|
'kf_name': dep_name,
|
||||||
|
'kf_id': dep_id,
|
||||||
|
'sort': 1,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'tp_year': tp_year}
|
||||||
|
response = requests.post(url=url, data=params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
table_data = [[cell.text for cell in row()]
|
||||||
|
for row in BeautifulSoup(response.text, 'lxml')("tr")]
|
||||||
|
|
||||||
|
dictOfWords = {i: table_data[i] for i in range(0, len(table_data))}
|
||||||
|
|
||||||
|
return (json.dumps(dict(dictOfWords), ensure_ascii=False))
|
||||||
|
|
||||||
|
def getTeachPlan(tp_year, sem_no, teach_id, teach_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"
|
||||||
|
#tab=8&tp_year=20&sem_no=1&pr_id=2162&pr_name=%D0%90%D0%B1%D0%B1%D0%B0%D1%81%D0%BE%D0%B2+%D0%AD.%D0%9C.
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'tab': '8',
|
||||||
|
'tp_year': tp_year,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'pr_id': teach_id,
|
||||||
|
'pr_name': teach_name
|
||||||
|
}
|
||||||
|
response = requests.post(url=url, data=params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
table_data = [[cell.text for cell in row()]
|
||||||
|
for row in BeautifulSoup(response.text, 'lxml')("tr")]
|
||||||
|
|
||||||
|
dictOfWords = {i: table_data[i] for i in range(0, len(table_data))}
|
||||||
|
|
||||||
|
return (json.dumps(dict(dictOfWords), ensure_ascii=False))
|
||||||
|
|
||||||
|
def getGroupId(gp_name):
|
||||||
|
allGp = getGroups()
|
||||||
|
gp_id = allGp.get(gp_name)
|
||||||
|
print(gp_id)
|
||||||
|
return gp_id
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
pr = getGroups(0)
|
||||||
|
print(pr)
|
||||||
|
|
||||||
114
app.py
Normal file
114
app.py
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
from flask import Flask, redirect, request
|
||||||
|
from manual import man
|
||||||
|
import actions
|
||||||
|
import table_actions as t_actions
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
groups = actions.getGroups()
|
||||||
|
dept = actions.getDepart()
|
||||||
|
teach = actions.getTeach()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def hello():
|
||||||
|
return redirect("/api/v1.0/manual", code=302)
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def not_found(e):
|
||||||
|
return redirect("/api/v1.0/manual", code=302)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/tplan1', methods=['GET'])
|
||||||
|
def getTplan1():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/tplan1?gp_name=2мбд1
|
||||||
|
gp_name = request.args.get('gp_name', None)
|
||||||
|
gp_id = groups[gp_name.lower()]
|
||||||
|
return actions.getFastPlan(gp_name, gp_id)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/table/tplan1', methods=['GET'])
|
||||||
|
def getTableTplan1():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/table/tplan1?gp_name=2мбд1
|
||||||
|
gp_name = request.args.get('gp_name', None)
|
||||||
|
gp_id = groups[gp_name.lower()]
|
||||||
|
return t_actions.getFastPlanTable(gp_name, gp_id)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/tplan2', methods=['GET'])
|
||||||
|
def getTplan2():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/tplan2?gp_name=2мбд1&sem_no=1&tp_year=19
|
||||||
|
gp_name = request.args.get('gp_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
gp_id = groups[gp_name.lower()]
|
||||||
|
return actions.getExtPlan(gp_name, gp_id, sem_no, tp_year)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/table/tplan2', methods=['GET'])
|
||||||
|
def getTableTplan2():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/table/tplan2?gp_name=2мбд1&sem_no=1&tp_year=19
|
||||||
|
gp_name = request.args.get('gp_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
gp_id = groups[gp_name.lower()]
|
||||||
|
return t_actions.getExtPlanTable(gp_name, gp_id, sem_no, tp_year)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/dep_plan', methods=['GET'])
|
||||||
|
def getDplan():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/dep_plan?dep_name=физики&sem_no=1&tp_year=19
|
||||||
|
dep_name = request.args.get('dep_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
dep_id = dept[dep_name.lower()]
|
||||||
|
return actions.getDeptPlan(dep_name, dep_id, sem_no, tp_year)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/table/dep_plan', methods=['GET'])
|
||||||
|
def getTableDplan():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/table/dep_plan?dep_name=физики&sem_no=1&tp_year=19
|
||||||
|
dep_name = request.args.get('dep_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
dep_id = dept[dep_name.lower()]
|
||||||
|
return t_actions.getDeptPlanTable(dep_name, dep_id, sem_no, tp_year)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/teach_plan', methods=['GET'])
|
||||||
|
def getTeacPlan():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/teach_plan?teach_name=суркова%20н.е.&sem_no=1&tp_year=19
|
||||||
|
teach_name = request.args.get('teach_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
teach_id = teach[teach_name.lower()]
|
||||||
|
return actions.getTeachPlan(tp_year, sem_no, teach_id, teach_name)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/table/teach_plan', methods=['GET'])
|
||||||
|
def getTableTeacPlan():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/table/teach_plan?teach_name=суркова%20н.е.&sem_no=1&tp_year=19
|
||||||
|
teach_name = request.args.get('teach_name', None)
|
||||||
|
sem_no = request.args.get('sem_no', None)
|
||||||
|
tp_year = request.args.get('tp_year', None)
|
||||||
|
teach_id = teach[teach_name.lower()]
|
||||||
|
return t_actions.getTeachPlanTable(teach_name, teach_id, sem_no, tp_year)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/groups', methods=['GET'])
|
||||||
|
def getGroupsDict():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/groups
|
||||||
|
return actions.getGroups(returnJson = 1)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/groupslist', methods=['GET'])
|
||||||
|
def getGroupsListDict():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/groups
|
||||||
|
return actions.getGroupsList(returnJson = 1)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/departaments', methods=['GET'])
|
||||||
|
def getDepartDict():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/departaments
|
||||||
|
return actions.getDepart(returnJson = 1)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/teaches', methods=['GET'])
|
||||||
|
def getTeachDict():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/teaches
|
||||||
|
return actions.getTeach(returnJson = 1)
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/manual', methods=['GET'])
|
||||||
|
def getManual():
|
||||||
|
# http://127.0.0.1:5000/api/v1.0/manual
|
||||||
|
return man()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True,host='0.0.0.0', port=5501)
|
||||||
52
manual.py
Normal file
52
manual.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
def man():
|
||||||
|
return(
|
||||||
|
'''
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Инструкция к API "Расписание МАДИ"</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Получить список групп</h2>
|
||||||
|
<h3>Обновлено 7.11.2020</h3>
|
||||||
|
<p><a href=/api/v1.0/groups>/api/v1.0/groups</a></p>
|
||||||
|
|
||||||
|
<h2>Получить список кафедр</h2>
|
||||||
|
<h3>Обновлено 7.11.2020</h3>
|
||||||
|
<p><a href=/api/v1.0/departaments>/api/v1.0/departaments</a></p>
|
||||||
|
|
||||||
|
<h2>Получить список преподавателей</h2>
|
||||||
|
<h3>Обновлено 8.11.2020</h3>
|
||||||
|
<p><a href=/api/v1.0/teaches>/api/v1.0/teaches</a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание для группы в json (метод GET)</h2>
|
||||||
|
<h3>Обновлено 8.11.2020</h3>
|
||||||
|
<p><a href=/api/v1.0/tplan1?gp_name=2мбд1>/api/v1.0/tplan1?<gp_name></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание для группы в HTML (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/table/tplan1?gp_name=2мбд1>/api/v1.0/table/tplan1?<gp_name></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расширенное расписание для группы в json (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/tplan2?gp_name=2мбд1&sem_no=1&tp_year=19>/api/v1.0/tplan2?<gp_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расширенное расписание для группы в HTML (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/table/tplan2?gp_name=2мбд1&sem_no=1&tp_year=19>/api/v1.0/table/tplan2?<gp_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание по кафедре в json (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/dep_plan?dep_name=физики&sem_no=1&tp_year=19>/api/v1.0/dep_plan?<dep_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание по кафедре в HTML (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/table/dep_plan?dep_name=физики&sem_no=1&tp_year=19>/api/v1.0/table/dep_plan?<dep_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание по преподавателю в json (метод GET)</h2>
|
||||||
|
<h3>Обновлено 8.11.2020</h3>
|
||||||
|
<p><a href=/api/v1.0/teach_plan?teach_name=суркова%20н.е.&sem_no=1&tp_year=19>/api/v1.0/teach_plan?<teach_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
<h2>Получить расписание по преподавателю в HTML (метод GET)</h2>
|
||||||
|
<p><a href=/api/v1.0/table/teach_plan?teach_name=суркова%20н.е.&sem_no=1&tp_year=19>/api/v1.0/table/teach_plan?<teach_name>&<sem_no>&<tp_year></a></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
|
)
|
||||||
9
proxy.py
Normal file
9
proxy.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
http_proxy = "http://10.10.10.3:3128"
|
||||||
|
https_proxy = "https://10.10.10.3:3128"
|
||||||
|
ftp_proxy = "ftp://10.10.10.3:3128"
|
||||||
|
|
||||||
|
proxyDict = {
|
||||||
|
"http" : http_proxy,
|
||||||
|
"https" : https_proxy,
|
||||||
|
"ftp" : ftp_proxy
|
||||||
|
}
|
||||||
76
table_actions.py
Normal file
76
table_actions.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import requests
|
||||||
|
from proxy import proxyDict
|
||||||
|
def getFastPlanTable(gp_name, gp_id):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '7',
|
||||||
|
'gp_name': gp_name,
|
||||||
|
'gp_id': gp_id}
|
||||||
|
response = requests.post(url = url, data = params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
return(response.text)
|
||||||
|
|
||||||
|
def getExtPlanTable(gp_name, gp_id, sem_no, tp_year):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '7',
|
||||||
|
'gp_name': gp_name,
|
||||||
|
'gp_id': gp_id,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'tp_year': tp_year}
|
||||||
|
response = requests.post(url = url, data = params, headers=headers, proxies=proxyDict,verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
return(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
def getDeptPlanTable(dep_name, dep_id, sem_no, tp_year):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '11',
|
||||||
|
'kf_name': dep_name,
|
||||||
|
'kf_id': dep_id,
|
||||||
|
'sort': 1,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'tp_year': tp_year}
|
||||||
|
response = requests.post(url = url, data = params, headers=headers, proxies=proxyDict,verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
return(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
def getTeachPlanTable(teach_name, teach_id, sem_no, tp_year):
|
||||||
|
headers = {'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
|
||||||
|
|
||||||
|
url = "http://tplan.madi.ru/tasks/tableFiller.php"
|
||||||
|
params = {
|
||||||
|
'tab': '8',
|
||||||
|
'pr_name': teach_name,
|
||||||
|
'pr_id': teach_id,
|
||||||
|
'sem_no': sem_no,
|
||||||
|
'tp_year': tp_year}
|
||||||
|
response = requests.post(url = url, data = params, headers=headers, proxies=proxyDict, verify=False)
|
||||||
|
response.encoding = 'utf-8'
|
||||||
|
|
||||||
|
return(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
getFastPlanTable()
|
||||||
|
|
||||||
|
|
||||||
16
tests.py
Normal file
16
tests.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!flask/bin/python
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import os
|
||||||
|
from app import app
|
||||||
|
|
||||||
|
class BasicTestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.app = app.test_client()
|
||||||
|
|
||||||
|
def test_main_page(self):
|
||||||
|
response = self.app.get('/api/v1.0/manual', content_type='html/text')
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user