Skip to content
Snippets Groups Projects
Commit 84443c65 authored by Hague Matthew UXAC009's avatar Hague Matthew UXAC009
Browse files

add(timetable): add ACADEMIC_YEAR to get-practical-groups

parent 0e5d0bd7
Branches
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# #
# Pay attention to the following variables # Pay attention to the following variables
# #
# ACADEMIC_YEAR -- should be e.g. 2425 else will try the wrong timetable
#
# CA_CERTS -- i need to configure this because the built-in Python # CA_CERTS -- i need to configure this because the built-in Python
# certs don't validate the timetabling system for some reason. # certs don't validate the timetabling system for some reason.
# #
...@@ -42,6 +44,16 @@ if len(sys.argv) < 2: ...@@ -42,6 +44,16 @@ if len(sys.argv) < 2:
student_list_csv = sys.argv[1] student_list_csv = sys.argv[1]
ACADEMIC_YEAR = "2425"
TT_HOST = "webtimetables.royalholloway.ac.uk"
TT_HOME_URL = f"https://{TT_HOST}/"
BASE_URL = f"{TT_HOME_URL}/SWS/SDB{ACADEMIC_YEAR}SWS"
TT_LOGIN_URL = f"{BASE_URL}/Login.aspx"
TT_DEFAULT_URL = f"{BASE_URL}/default.aspx"
USER_AGENT \
= "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
MODULE_CODE = "CS1822" MODULE_CODE = "CS1822"
DEPARTMENTS = ["Computer Science", "Media Arts"] DEPARTMENTS = ["Computer Science", "Media Arts"]
...@@ -63,10 +75,10 @@ USERNAME = "uxac009" ...@@ -63,10 +75,10 @@ USERNAME = "uxac009"
PASSWORD = getpass(f"Password for {USERNAME}: ") PASSWORD = getpass(f"Password for {USERNAME}: ")
HEADERS = { HEADERS = {
"Host": "webtimetables.royalholloway.ac.uk", "Host": TT_HOST,
"Origin": "https://webtimetables.royalholloway.ac.uk", "Origin": TT_HOME_URL,
"Referer": "https://webtimetables.royalholloway.ac.uk/SWS/SDB2324SWS/default.aspx", "Referer": TT_DEFAULT_URL,
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0" "User-Agent": USER_AGENT
} }
BATCH_SIZE = 50 BATCH_SIZE = 50
...@@ -99,7 +111,7 @@ def update_form_data(response, form_data): ...@@ -99,7 +111,7 @@ def update_form_data(response, form_data):
def initialise_form_data(form_data): def initialise_form_data(form_data):
response = requests.get( response = requests.get(
"https://webtimetables.royalholloway.ac.uk/", TT_HOME_URL,
headers=HEADERS, headers=HEADERS,
verify=CA_CERTS verify=CA_CERTS
) )
...@@ -107,7 +119,7 @@ def initialise_form_data(form_data): ...@@ -107,7 +119,7 @@ def initialise_form_data(form_data):
def login(form_data): def login(form_data):
response = requests.post( response = requests.post(
"https://webtimetables.royalholloway.ac.uk/SWS/SDB2324SWS/Login.aspx", TT_LOGIN_URL,
data = form_data | { data = form_data | {
"tUserName": USERNAME, "tUserName": USERNAME,
"tPassword": PASSWORD, "tPassword": PASSWORD,
...@@ -121,7 +133,7 @@ def login(form_data): ...@@ -121,7 +133,7 @@ def login(form_data):
def make_request(form_data, cookies): def make_request(form_data, cookies):
response = requests.post( response = requests.post(
"https://webtimetables.royalholloway.ac.uk/SWS/SDB2324SWS/default.aspx", TT_DEFAULT_URL,
data=form_data, data=form_data,
cookies=cookies, cookies=cookies,
headers=HEADERS, headers=HEADERS,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment