Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
phantomjs --ignore-ssl-errors=true --load-images=no --ssl-protocol=tlsv1 gradeCheck.js
// Example using HTTP POST operation
var username = "USERNAME"; // must be all capitalized
var pass = "password";
var page = require('webpage').create();
var server = 'https://www.spire.umass.edu/psp/heproda/';
var data = 'userid='+username+'&pwd='+pass+'&languageCd=ENG&timezoneOffset=0&Submit=Go&cmd=login';
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.74.9 (KHTML, like Gecko) Version/7.0.2 Safari/537.74.9';
page.viewportSize = { width: 800, height: 800 };
page.open(server, 'post', data, function (status) {
if (status !== 'success') {
console.log(page.content);
console.log('Unable to post!');
} else {
console.log("logged in");
setTimeout(loadPage, 3000);
}});
function loadPage()
{
page.open('https://www.spire.umass.edu/psc/heproda/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSR_SSENRL_GRADE.GBL?FolderPath=PORTAL_ROOT_OBJECT.HCCC_ACADEMIC_RECORDS.HC_SSR_SSENRL_GRADE_GBL&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder', function(status){
console.log(status);
page.evaluate(function(){
if (window._phantom) {
// Patch since PhantomJS does not implement click() on HTMLElement. In some
// cases we need to execute the native click on an element. However, jQuery's
// $.fn.click() does not dispatch to the native function on <a> elements, so we
// can't use it in our implementations: $el[0].click() to correctly dispatch.
if (!HTMLElement.prototype.click) {
HTMLElement.prototype.click = function() {
var ev = document.createEvent('MouseEvent');
ev.initMouseEvent(
'click',
/*bubble*/true, /*cancelable*/true,
window, null,
0, 0, 0, 0, /*coordinates*/
false, false, false, false, /*modifier keys*/
0/*button=left*/, null
);
this.dispatchEvent(ev);
};
}
}
document.getElementById('DERIVED_SSS_SCT_SSS_TERM_LINK').click();
setTimeout(function(){document.getElementById('SSR_DUMMY_RECV1$sels$1$$0').click(); setTimeout(function(){document.getElementById('DERIVED_SSS_SCT_SSR_PB_GO').click()}, 500);}, 500);
});
setTimeout(function()
{
page.clipRect = page.evaluate(function() {
return document.getElementById('ACE_DERIVED_SSS_GRD_GROUPBOX2').getBoundingClientRect();
});
page.render("grades.png");
phantom.exit();
}, 2000);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment