<commit_before>import * as request from 'request';
import * as htmlparser from 'htmlparser';

var gamelist: string[] = require("./gamelist/games.json");


function getGamePage(gameName: string) {
    var url = encodeURI("https://www.google.co.uk/search?q=" + gameName + " site:store.steampowered.com&btnI");
    request(url, {}, (e, r, body) => {
        var options = {
            url: url,
            features: {
                removeScript: true //Remove scripts for innerHTML and outerHTML output
            }
        };
        var handler = new htmlparser.DefaultHandler(function (error, dom) {
            if (error) {

            }
            else {

            }
        });
        var parser = new htmlparser.Parser(handler);
        parser
    });
}


getGamePage(gamelist[0]);<commit_msg>playing around with parsers to find class<commit_after>import * as request from 'request';
import * as htmlparser from 'htmlparser';
import * as fs from 'fs';
import * as jsonQuery from 'json-query';

var gamelist: string[] = require("./gamelist/games.json");


function getGamePage(gameName: string): void {
    var url = encodeURI("https://www.google.co.uk/search?q=" + gameName + " site:store.steampowered.com&btnI");
    request(url, {}, (e, r, body) => {
        var options = {
            url: url,
            features: {
                removeScript: true //Remove scripts for innerHTML and outerHTML output
            }
        };
        var handler = getHtmlJsonHandler();
        var parser = new htmlparser.Parser(handler);
        parser.parseComplete(body);
    });
}

function getHtmlJsonHandler() {
    return new htmlparser.DefaultHandler(function (error, dom) {
        if (error) { }
        else {
            var json = JSON.stringify(dom);
            fs.writeFileSync("dump/dom.json", json);
            searchJson(json);
        }
    });
}
function searchJson(json: any): void {
    var helper = {
        searchForClass: (input:any, className:string):any => {
            //if attribs contains class add to return list
            //search children
            // return array of classes
        }
    };
    var testJson = [
        {
            children: [
                { children: [{ "name": "one", "data": "123" }, { "name": "two", "data": "234" }] }
            ]
        }];
    var pattern = "[**][*name=one].name";
    //var pattern = `[**][*.name=body].name`;
    var out = jsonQuery(pattern, { data: testJson });
    console.log(out.value);

}

var tagsOnPage = "glance_tags_ctn popular_tags_ctn";

//getGamePage(gamelist[0]);

var json = require("./dump/dom.json");

searchJson(json);
{'fraction_non_alphanumeric': 0.1430197268588771, 'fraction_numerical': 0.0030349013657056147, 'mean_word_length': 2.2276621787025706, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 6, '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': '3771700', 'n_tokens_mistral': 794, 'n_tokens_neox': 770, 'n_words': 191}