Skip to content

Instantly share code, notes, and snippets.

@zszszsz
Last active August 30, 2017 16:00
Show Gist options
  • Save zszszsz/352417e0db63b5c715b61ae8663b0d22 to your computer and use it in GitHub Desktop.
Save zszszsz/352417e0db63b5c715b61ae8663b0d22 to your computer and use it in GitHub Desktop.
njit intl hold test
const https = require('https');
const options = {
hostname: 'myhub.njit.edu',
path: '/StudentRegistrationSsb/ssb/term/search?mode=registration',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 69,
'X-Requested-With': 'XMLHttpRequest',
Cookie: 'your cookies here', //your cookies here
'X-Synchronizer-Token': 'your sync token here', // your sync token here
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0',
Referer: 'https://myhub.njit.edu/StudentRegistrationSsb/ssb/term/termSelection?mode=registration'
}
}
var timeout = 10000;
var count = 0;
function send() {
var buffer = '';
var req = https.request(options, res => {
res.on('data', chunk => buffer += chunk);
res.on('end', () => {
buffer = JSON.parse(buffer);
console.log(count + '\n***************\n' + buffer["studentEligFailures"][0] + '\n*************\n');
count += 1;
if (buffer["studentEligValid"]) {
console.log('true');
process.exit(0);
}
if(!buffer["studentEligFailures"]) {
console.log('renew your cookie');
process.exit(0);
}
setTimeout(send, timeout);
});
});
req.write('term=201790&studyPath=&studyPathText=&startDatepicker=&endDatepicker=');
req.end();
}
send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment