Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

OB42/parsonic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

parsonic

Parsonic is a node.js wrapper for the native Chromium HTML DOMParser,

once it's loaded, parsonic is ~3x times faster than cheerio

Here is an example:

var parsonic = require("parsonic");
var request = require("request");
request("https://github.com", (err, res, html) => {
	parsonic.load(html, {selector:"*", anyData:"Hello world!"}, function(document, args){
		/*We're out of Node.js scope, we can only use data from "args" and document,
		however this is not headless scraping: <script> are not executed and window isn't accessible.
		You can't return a DOM element, you must return your own variables/objects.*/
		return document.querySelectorAll(args.selector).length
	},
	(err, results) => {
		if (err)
		{
			console.log(err)
		}
		else{
			/*We're back in Node.js, with the value that we returned*/
			console.log(results)
		}
	});
});

If you don't need parsonic anymore, you can kill it to free memory using parsonic.close().

About

Ultra fast HTML parser module for Node.js, using native chromium functions and Nightmarejs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published