seize
Seize is light Node or Browser web-page content extractor inspired by arc90 readability and Safari Reader.
Install
npm i --save seize
Usage
Seize can be used with DOM libraries such as jsdom for example. It only extracts and prepares certain DOM-node for further usage.
Example
var Seize = jsdom = jsdom; var window = defaultView seize = windowdocument; seizecontent; // returns DOM-nodeseizetext; // returns only text
Browser usage
For browser usage you shoud clone you DOM object or create it from HTML string:
/** * Converts html string to Document * @param * @return */{ var doc = documentimplementation; docdocumentElementinnerHTML = html; return doc;};
How it works
Here is algorythm how it works:
- Getting html tags that we expect to be text or content container such as
p
,table
,img
, etc. - Filtering unnesessary tags by content and tag names wich defenantly can't be in a content container
- Setting score for each container by containing tags
- Setting score by class name, id name, tag xPath score and text score
- Sorting canditates by score
- Taking first candidate
- Cleaning up article
Todo
Seize still in development, so you can use it at one's own risk. You always can help to improve it.
- Improve readme
- Improve text scoring
- Improve page detection wich can't be extracted
- More tests
- More examples
Contributing
You are welcomed to improve this small piece of software :)