Created
April 25, 2014 17:06
-
-
Save EhsanKia/11296465 to your computer and use it in GitHub Desktop.
Fetches transcript from minerva
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
LOGIN_URL = "https://horizon.mcgill.ca/pban1/twbkwbis.P_ValLogin" | |
DATA_URL = "https://horizon.mcgill.ca/pban1/bzsktran.P_Display_Form" | |
def login(username, password): | |
info = {"sid": username, "PIN": password} | |
cookies = {"TESTID": "set"} | |
r = requests.post(LOGIN_URL, data=info, cookies=cookies) | |
return r.cookies.get("SESSID") | |
def get_transcript(session): | |
req_filter = "user_type=S&tran_type=V" | |
cookies = {"SESSID": session} | |
r = requests.post(DATA_URL, data=req_filter, cookies=cookies) | |
return r.content | |
session_id = login("[email protected]", "hunter2") | |
with open("transcript.html", "w") as f: | |
f.write(get_transcript(session_id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment