Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- login = input('Login:')
- password = input('Password:')
- score_dict = {'classwork': 0, 'homework': 0, 'additional': 0}
- score_dict_all = {'classwork': 0, 'homework': 0, 'additional': 0}
- s = requests.Session()
- auth = s.post('https://passport.yandex.ru/passport?mode=auth',
- data={'login': login, 'passwd': password})
- if auth.url == 'https://passport.yandex.ru/profile':
- print('Авторизация прошла успешно')
- print('--------------------------')
- else:
- if 'Неправильный' in auth.text:
- raise Exception('Неправильные логин или пароль')
- raise Exception('Ошибка X')
- courses_url = r'https://lyceum.yandex.ru/api/profile'
- courses = s.get(url=courses_url, params={'onlyActiveCourses': True,
- 'withCoursesSummary': True,
- 'withExpelled': True}).json()['coursesSummary'][
- 'student']
- course_id = courses[1]['id']
- group_id = courses[1]['group']['id']
- lessons = s.get(url='https://lyceum.yandex.ru/api/student/lessons',
- params={'courseId': course_id, 'groupId': group_id}).json()
- for lesson in lessons:
- lesson_id = lesson['id']
- lesson_tasks = s.get('https://lyceum.yandex.ru/api/student/lessonTasks',
- params={'courseId': course_id, 'lessonId': lesson_id}).json()
- for tasks_group in lesson_tasks:
- for task in tasks_group['tasks']:
- sol = task['solution']
- if sol:
- if sol['status']['type'] == 'review':
- score_dict[task['tag']['type']] += task['scoreMax']
- score_dict_all[task['tag']['type']] = score_dict_all.get(task['tag']['type'], 0) + task['scoreMax']
- k = len(str(
- max([score_dict['classwork'], score_dict['homework'], score_dict['additional']], key=lambda s: len(str(s)))))
- rating = courses[1]['rating']
- rating_all = score_dict_all['classwork'] / 100 * 0.3 + score_dict_all['homework'] / 100 * 0.3 + score_dict_all[
- 'additional'] / 100 * 1.2 + score_dict_all['individual-work'] * 0.1 + score_dict_all['control-work'] * 0.2
- impulse_score = score_dict['classwork'] / 100 * 0.3 + score_dict['homework'] / 100 * 0.3 + score_dict[
- 'additional'] / 100 * 1.2
- print('Классные задачи: ', score_dict['classwork'], ' ' * (k - len(str(score_dict['classwork']))),
- score_dict['classwork'] / 100 * 0.3)
- print('Домашние задачи: ', score_dict['homework'], ' ' * (k - len(str(score_dict['homework']))),
- score_dict['homework'] / 100 * 0.3)
- print('Дополнительные задачи:', score_dict['additional'], ' ' * (k - len(str(score_dict['additional']))),
- score_dict['additional'] / 100 * 1.2)
- print('--------------------------')
- print('Баллы без проверки:', round(rating, 2))
- print('Баллы для проверки:', impulse_score)
- print('Баллы с проверкой: ', round(rating + impulse_score, 2))
- print(score_dict_all)
- print('Возможные баллы с проверкой: ', round(rating_all, 2))
- input('Жмякай Enter')
Add Comment
Please, Sign In to add comment