The goal of this project is to use a cloud service like AWS or GCP and create a cron job in order to run them at specific intervals
The script first webscrapes VSB to determine if there is a place available in the class, then it will proceed to register. If you think that I'm stealing your credentials for minerva, just go look at the source code, it is 148 lines.
WARNING: This program is to be used with people with knowledge with cloud infrastructure and node.js. I tried my best to make the instructions clear but anyone with any prior knowledge should be able to figure things out. Contact me if you need help!
- rename
sample.env
to.env
- rename
sample.env.yml
to.env.yml
- fill out both
.env
file. The yml file is used for google cloud function whereas the regular one is for local
DO NOT touch the package.json
in the src
folder as they are used for deploying through the CLI.
- Go on VSB and copy the URL after you have chosen your classes.
- Modify the content of
config
JSON insrc/function.js
to match yours. - The CRN is a list of all CRN of the class you would like to register. Those can be found on VSB also.
- To run, simply write
npm install
thennpm start
from the root of this project in your command line.
Available function name:
closedSection
for closed section classmulticlass
for multiclass registration on one functionwaitlist
for a waitlist classwaitlistNotify
for receving an email when wait list has a new empty seat
Readme in src
folder has more detailed information
Assuming you have a project and already logged in. During this process, it ask you to enable some API, simply hit yes. To deploy a function, simply run
gcloud functions deploy FUNCTION_NAME --source=src/FOLDER --trigger-http --allow-unauthenticated --env-vars-file=.env.yml --runtime=nodejs14 --memory=512MB
Give it a function name and make sure to mark the correct source folder for the script you want to deploy.
This will return a httpsTrigger url
and you can use that in cloud scheduler.
gcloud scheduler jobs create http NAME --schedule "* * * * 15" --uri=HTTPURL --http-method GET
Give the cloud scheduler a NAME
, make sure to change the schedule
and the uri
. It is currently set for every 15 min.
You can use crontab guru to customize it. The more frequent you run it, the higher your bill will be.
Feel free to customize the rest of the fields to your liking, but those are the basics to run the project on GCP.
- Create a Cloud Function with content of
src/SCRIPT_YOU_WANT/function.js
. Use HTTP Trigger, 512mb of ram, function to execute is theexport.FUNCTIONNAME
, allow unauthorized requests (makes life easier). - Modify the
config
json variable as needed in the script. - Use the following
package.json
for GCP since thenpm start
is slightly different from the one located at the root of the project.
{
"name": "mcgill-autoregistration",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "index.(your_chosen_function)"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer": "^2.1.1",
"@sendgrid/mail": "^6.5.5",
"dotenv": "^8.2.0",
}
}
- Once deployed, create Cloud Scheduler that calls the url generated by the function with a
GET
request. Choose an appropriate frequency (The more you run the function, the higher the costs!)
4.1 I'm running mine every 30mins or so, if you would like to customize the time use this amazing tool
If you do not want to have email notifications, set "wantEmail": false
in config.wantEmail
.
To receive emails follow these steps:
- Sign up on sendgrid.
- Copy down the API key and use it in the program.
- Write your email on line 110 of
function.js
.
A free trial should be more than enough for our purposes as we get 100 free emails a day.
Below, all the fields of the config
JSON are described
email
: McGill Minerva usernamepassword
: McGill Minerva passwordterm
: Term you wish to register for, found in VSB URL (ex. term=202005)CRN
: List of CRNs you wish to register for, found in VSB at bottom of screenurl
: Select the classes you want on VSB for your selected term then copy the URL overwantEmail
: Set to true if you want an email notification upon successful registrationnotifEmail
: Where to send notification email to, leave as""
if wantEmail is falsesgApiKey
: Received when registered for sendgrid, leave as""
if wantEmail is false
- There is a MAXIMUM of 10 CRN that you can have, those included the tutorial's CRN.
- Each CRN must be comma separated with NO SPACE
- The
semester
field needs to follow this pattern: YYYYMM - YYYY represents the academic year
- MM is the semester where Fall is 09, Winter is 01, Summer is 05.
For example, if I want to register for fall 2020, I would write 202009. - The script checks on vsb first to see if there are spots in the class. If so, it will proceed to register on Minerva. This is to prevent using all the registration limit which is around 1000 per semester.
- To run on the cloud, we need to use the headless version of chrome
headless: true
, if you want to see the browser, simply set toheadless: false
infunction.js
. - You can have conflicting classes schedule in VSB, the program will still work like this:
You will need to find the CRN of them separately because VSB will not generate a schedule for you.
Currently I want to register to all the classes shown in the image for the summer term, my config
variable will look like this:
const config = {
"regEmail": "[email protected]",
"password": "password",
"term": "202005",
"CRN": "527,528,491,850,285,288,289",
"url": "https://vsb.mcgill.ca/vsb...",
"wantEmail": true,
"notifEmail": "",
"sgApiKey": "SG.xxx..."
};
Notice how CRN 527 (lecture) and 528 (tutorial) for FACC300 is inputted.
- Ping VSB, and check if the class is free. If yes, proceed to register.
- Log files generated by local script.
- Make code more modular (Help needed!).
- Determine the update frequency on VSB
Create an issue and we will talk about it!