<commit_before>
var casper = require('casper').create();
var mouse = require("mouse").create(casper);
var fs = require('fs');

// usage: casperjs fiddling.js file://localhost`pwd`/examples/facebook.html

// navigate straight to relevant asp page

var startUrl = (casper.cli.args.length > 0)
    ? casper.cli.args[0]
    : 'https://www.questnet.sg/Maincontent.asp';

casper.start(startUrl, function() { // INSERT YOUR LOCAL FILE HERE
    this.echo(startUrl + " loaded");
});

casper.then(function() {

	// make dom elements available to casperjs
	
	var keyArr = [];
	var valArr = [];	
	
	var elements = this.getElementsInfo('td.lblFld');
	for (var i = 0; i < elements.length; i++) {
	    keyArr.push(elements[i].text);
	}
	var val = this.getElementsInfo('td.DtaFld');
	for (var i = 0; i < val.length; i++) {
	    valArr.push(val[i].text);
	}

	this.echo(keyArr);
	this.echo(valArr);
	this.echo('Getting details');
	var info = initialInfo(keyArr, valArr);
	
	fs.write('results.json', JSON.stringify(info, null, 2), 'w');
	this.echo('Done!');
});

casper.withFrame('main', function() {
    casper.withFrame('contentFrame', function() {
	fs.write('results.html', this.getHTML(), 'w');
    });
});

casper.run();


// parser constructor functions

function initialInfo(keys, values) {
    var result = {};

    // we get the initial general information first

    for (var i = 0; i < keys.length; i++) {
	if (keys[i] == 'Capital Structure') {
	    break; 
	};
	result[keys[i]] = values[i];
    };<commit_msg>preserve original HTML for later parsing<commit_after>
var casper = require('casper').create();
var mouse = require("mouse").create(casper);
var fs = require('fs');

// usage: casperjs fiddling.js file://localhost`pwd`/examples/facebook.html

// navigate straight to relevant asp page

var startUrl = (casper.cli.args.length > 0)
    ? casper.cli.args[0]
    : 'https://www.questnet.sg/Maincontent.asp';

casper.start(startUrl, function() { // INSERT YOUR LOCAL FILE HERE
    this.echo(startUrl + " loaded");
});

casper.then(function() {

	// make dom elements available to casperjs
	
	var keyArr = [];
	var valArr = [];	
    var htmlArr = this.getElementsInfo('td.DtaFld').map(function(e) { return e.html } );
    var nricArr = this.evaluate(function() {
        var elements = __utils__.findAll('td.DtaFld a.searchlink');
        return elements.map(function(e) {
          return e.text;
        });
    });
  
	var elements = this.getElementsInfo('td.lblFld');
	for (var i = 0; i < elements.length; i++) {
	    keyArr.push(elements[i].text);
	}
	var val = this.getElementsInfo('td.DtaFld');
	for (var i = 0; i < val.length; i++) {
	    valArr.push(val[i].text);
	}

	this.echo(keyArr);
    this.echo(valArr);
    this.echo(htmlArr);
    this.echo(nricArr);
	this.echo('Getting details');
	var info = initialInfo(keyArr, valArr);
	
	fs.write('results.json', JSON.stringify(info, null, 2), 'w');
	this.echo('Done!');
});

casper.withFrame('main', function() {
    casper.withFrame('contentFrame', function() {
	fs.write('results.html', this.getHTML(), 'w');
    });
});

casper.run();


// parser constructor functions

function initialInfo(keys, values) {
    var result = {};

    // we get the initial general information first

    for (var i = 0; i < keys.length; i++) {
	if (keys[i] == 'Capital Structure') {
	    break; 
	};
	result[keys[i]] = values[i];
    };
{'fraction_non_alphanumeric': 0.18020154119739182, 'fraction_numerical': 0.0035566093657379964, 'mean_word_length': 3.573170731707317, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '194239', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1157, 'n_words': 261}