[M] Move non-course-related files to misc

This commit is contained in:
Hykilpikonna
2021-12-22 01:03:28 -05:00
parent 12b83a05dd
commit f1e4cd9488
24 changed files with 1 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
import re
import requests
def get_course_info(id: str):
link = f'https://artsci.calendar.utoronto.ca/course/{id}'
html = requests.get(link).text
name: str = re.findall(r'(?<=<h1 class="title page-title">).*(?=<)', html)[0]
name = ': '.join(name.split(': ')[1:])
hours_raw = re.findall(r'(?<=<div class="field__item"><p>).*(?=<)', html)
hours: str = '0N' if len(hours_raw) == 0 else hours_raw[0]
hours = '/'.join([str(int(it[:-1]) / 12) + it[-1] for it in hours.split('/')])
return {'id': id, 'name': name, 'link': link, 'hours': hours,
'full': f'`{id}` - [{hours}] [{name}]({link})'}
if __name__ == '__main__':
sep = input('Please enter the separator (Eg. a comma): ')
l = input(f'Please enter course codes separated by "{sep}": ')
[print(get_course_info(it.strip().strip(' '))['full'] + ' ') for it in l.split(sep)]