--------------------
/*
*
* unco_dept.js: test to take input url
*
* casper.js unco_dept.js --url="foo" --cfile="dd"
*
https://insight.unco.edu/approot/unc/schedule.htm*
*/
var casper = require('casper').create({
verbose: true,
logLevel: "debug",
waitTimeout: 25000, // new maximum waitTimeout
pageSettings:
{
userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0'
}
});
phantom.timeout=20000;
phantom.stepTimeout=20000;
var x = require('casper').selectXPath;
phantom.cookiesEnabled = true;
var url = casper.cli.get("url");
var cfile = casper.cli.get("cfile");
//var cookie_file = cfile;
//var fs = require('fs')
//var data = fs.read(cookie_file);
//phantom.cookies = JSON.parse(data);
//casper.echo('cookie: ' + JSON.stringify(phantom.cookies));
//var processPage = function() {
// this.echo(this.page.content);
//};
casper.start(url);
//casper.waitForSelector('input[id="conversionId"]', processPage);
//casper.waitForSelector("//div[class='addcartform']", processPage);
//casper.waitForSelector('html', processPage);
//casper.waitForSelector(x('//tr[@linenum="1037"]'));
casper.waitForSelector(x('//option[@value="Aiken"]'));
//casper.run();
casper.run(function () {
// echo results in some pretty fashion
// this.echo(this.debugPage()).exit();
// fs.write(cookie_file, JSON.stringify(phantom.cookies), 644);
this.echo(this.page.content).exit();
});
-------------------