Automatically registers you on Minerva with Puppeteer and GCP
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!
sample.env
to .env
sample.env.yml
to .env.yml
.env
file. The yml file is used for google cloud function whereas the regular one is for localDO NOT touch the package.json
in the src
folder as they are used for deploying through the CLI.
config
JSON in src/function.js
to match yours. npm install
then npm 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 seatReadme 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
1.
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.
src/SCRIPT_YOU_WANT/function.js
. Use HTTP Trigger, 512mb of ram, function to execute is the export.FUNCTIONNAME
, allow unauthorized requests (makes life easier).config
json variable as needed in the script.package.json
for GCP since the npm 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",
}
}
GET
request. Choose an appropriate frequency (The more you run the function, the higher the costs!)\If you do not want to have email notifications, set "wantEmail": false
in config.wantEmail
.\
To receive emails follow these steps:
function.js
.A free trial should be more than enough for our purposes as we get 100 free emails a day.
.env
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 falsesemester
field needs to follow this pattern: YYYYMMheadless: true
, if you want to see the browser,headless: false
in function.js
. 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": "firstname.lastname@mail.mcgill.ca",
"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.
Create an issue and we will talk about it!