Not generating a basic page.

19 views
Skip to first unread message

bruce

unread,
Mar 28, 2016, 11:31:15 AM3/28/16
to casp...@googlegroups.com
Hi.

I've got a short test. should be simple, can't see what I'm missing.

The site:
   https://insight.unco.edu/approot/unc/schedule.htm

Inserting this into the browser, gets the data. The target is javascript.

I crafted a short test, and could never get the actual page.
The test uses a waitforselector for an option/value that actually does exist via the firebug/dom inspector

Any pointers on what's missing, would be appreciated. The test apparently times out, which indicates it's never getting to the selector. Without the selector, , and just doing a simple get, the returned content is the basic html/body

running casperjs/phantomjs/centos

casperjs unco_dept.js --url='https://insight.unco.edu/approot/unc/schedule.htm' --cfile='aa.lwp"

cookie/cfile - a generic/empty cookie file..
echo '{}' > aa.lwp


--------------------
/*
*
*    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();

});


-------------------
Reply all
Reply to author
Forward
0 new messages