locusbuilder-utility
Version:
Locusbuilder Utility server for asset scraping and processing
33 lines (29 loc) • 837 B
JavaScript
/**
* Module: HTML Parser
* @author Richard Abear
*
* @description HTML parser recieves a url and returns a fully processed output depending on request
*/
const phantom = require('phantom');
// Disable jshint for async programming
// jshint ignore: start
class HtmlParser {
constructor(opts) {
this.id = opts.id;
}
async init() {
console.log('Initializing phantomjs instance');
try {
this.instance = await phantom.create();
this.page = await this.instance.createPage();
} catch(e) {
console.log(e);
}
}
async openPage(page) {
const status = await this.page.open(page);
const content = await this.page.property('content');
return content;
}
}
module.exports = HtmlParser;