Skip to content

Instantly share code, notes, and snippets.

@chrisfosterelli
Created August 23, 2015 20:48
Show Gist options
  • Save chrisfosterelli/12427bbbe6300213afec to your computer and use it in GitHub Desktop.
Save chrisfosterelli/12427bbbe6300213afec to your computer and use it in GitHub Desktop.
// EXTREMELY hacky - sorry :P
var http = require('https');
var defaults = {'term_in':'201410',
'sel_subj':'dummy',
'sel_day':'dummy',
'sel_schd':'dummy',
'sel_insm':'dummy',
'sel_camp':'dummy',
'sel_levl':'dummy',
'sel_sess':'dummy',
'sel_instr':'dummy',
'sel_ptrm':'dummy',
'sel_attr':'dummy',
'sel_crse':'',
'sel_title':'',
'sel_from_cred':'',
'sel_to_cred':'',
'begin_hh':'0',
'begin_mi':'0',
'begin_ap':'a',
'end_hh':'0',
'end_mi':'0',
'end_ap':'a'};
var second = {
'sel_camp' : '%',
'sel_levl' : '%',
};
var thirds = ['COMP'];
var string = '';
for (var key in defaults) {
if (defaults.hasOwnProperty(key)) {
string += (key + '=' + defaults[key] + '&');
}
};
for (var key in second) {
if (defaults.hasOwnProperty(key)) {
string += (key + '=' + defaults[key] + '&');
}
};
thirds.forEach(function(key) {
string += ('sel_subj' + '=' + key + '&');
});
// An object of options to indicate where to post to
var post_options = {
host: 'banssbprod.tru.ca',
port: '443',
path: '/banprod/bwckschd.p_get_crse_unsec',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': string.length
}
};
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
post_req.write(string);
post_req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment