I wrote a script towards the end of my spring semester in 2015 that automated course registration for me. I was two days late to registering for fall 2015 when the registration window opened. At that time, all the classes I needed to get into were full and I was getting frustrated because what would happen is I’d get a notification that a spot freed up and I either wouldn’t get to the registration page on time or I’d be outside or in class, not able to log in.

A friend of mine jokingly challenged me to write the registration bot. I honestly thought I couldn’t do it. I didn’t know where to start. But I started to realize this could be super useful for all the students here at Penn State and so one weekend, I decided to throw hail Mary and get working on a script. To my geuine surprise, I actually had a working script! It was very hacky but hey, it worked!! WOHOO! It did take over a month to perfect the script though. I had a bunch of memory issues with scaling the script and what not.

The script was very simple. All it did was scrape the public page for searching classes every second (Thank God it was public) and check the capacity. If there was a spot that available, the script would then login using school e-mail and password and then navigate to the registration page and then add the course. Everything was done with Nokogiri + Mechanize (Ruby). It was all a matter of figuring out where to click to submit forms and just looking through the requests Chrome debugging tool and the request log to see what was being POST-ed. It was all pretty simple to figure out. Nothing extraordinary going on there.

Just a log output of the class seat query every few seconds. The key is the section course id and value is empty seats




Thoughts


I felt like the idea of making something like this was a little over the top for me because I didn’t think I’d be able to finish it let alone start it. Though, I nudged myself one day just to get started on this script and surprisingly, it didn’t seem too complicated work on at all. Two days of writing ruby code and viola, a working script that did everything I wanted!

I’d say that working on this project has given me a newfound confidence to work on ambitious projects I would’ve otherwise avoided. It has also changed my mentality on approaching projects: LESS THINKING, MORE WRITING! Of course it’s not the go-to approach to all kinds of projects. It’s just an approach to get started on projects and I like it because well, you immediately start working on the project!

TODO


There is an endpoint on Penn States web servers that allows you to query seat availability for courses. My script posts to that endpoint every few seconds or so and it’d be likely that someone would detect such an activity. So to work a way around this, I thought of having Penn States notification system send a text to a Twillio number instead of my personal number. That way I can set up a callback url to receive the text from Penn State and parse it to get the course and course level instead of having to overload Penn States webservers by posting to it every few seconds. Having received the course prefix and number