A scraper that simulates an API for UCSD's Schedule of Classes
Many thanks to andrewthehan and davidmrdavid
Check out a project made with socsjs! trendysocs.com
npm install socsjs --save
var socsjs = require('socsjs');
var quarter = 'FA16';
var query = 'CSE105';
var timeout = 5000;
socsjs.findCourse(quarter, query, timeout).then(function(result) {
console.log(result); // returns a Course
console.log(result.sections[0].isEnrollable); // true
}).catch(function(err) {
console.log(err, 'oops!');
});
var quarter = 'FA16';
var queries = ['cse11', 'cse12', 'WCWP10A'];
var timeout = 5000;
socsjs.findCourses(quarter, queries, timeout).then(function(result) {
console.log(result); // returns an array of Courses
}).catch(function(err) {
console.log(err, 'oops!');
});
var quarter = 'FA16';
var dept = 'ANTH';
var timeout = 10000;
socsjs.searchDepartment(quarter, dept, timeout).then(function(result) {
console.log(result); // returns an array of Courses
}).catch(function(err) {
console.log(err, 'oops!');
});
A Course
object has a String name
and an array sections
.
sections
is made up of CourseElements
A CourseElement
contains information about a Course
.
var CourseElement = function(type, id, section, days, time, location, teacher, openSeats, seatLimit) {
this.type = type; // String describing a course element (eg. 'final', 'discussion')
this.sectionID = id; // Null or String of the section's ID (eg. '123456')
this.section = section; // Null or String of the section (eg. 'A01')
this.days = days; // String of the days (eg. 'MWF')
this.time = time; // String of the time as shown on the Schedule of Classes site
this.location = location; // String of the location
this.teacher = teacher; // Null or String of LastName,FirstName of teacher
this.openSeats = openSeats; // Null or Number of how many seats are available
this.seatLimit = seatLimit; // Null or Number of the course element's class limit
this.waitlistSize = 0; // Null or Number of people on the waitlist
this.isEnrollable = false; // Boolean for if a class element is enrollable
}
- Add support for other Meeting Types
- Add filters to get information easily
- Fix error handling
- Set default timeout value
- Format CourseElement fields, such as setting time to have start/end or having proper spacing for teacher names