![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
node-readability
Advanced tools
Readme
Turn any web page into a clean view. This module is based on arc90's readability project.
article
, section
) and Microdata API.$ npm install node-readability
Note that as of our 2.0.0 release, this module only works with Node.js >= 2.0. In the meantime you are still welcome to install a release in the 1.x series(by npm install node-readability@1
) if you use an older Node.js version.
read(html [, options], callback)
Where
callback(error, article, meta)
Example
var read = require('node-readability');
read('http://howtonode.org/really-simple-file-uploads', function(err, article, meta) {
// Main Article
console.log(article.content);
// Title
console.log(article.title);
// HTML Source Code
console.log(article.html);
// DOM
console.log(article.document);
// Response Object from Request Lib
console.log(meta);
// Close article to clean up jsdom and prevent leaks
article.close();
});
NB If the page has been marked with charset other than utf-8, it will be converted automatically. Charsets such as GBK, GB2312 is also supported.
node-readability will pass the options to request directly. See request lib to view all available options.
node-readability has two additional options:
cleanRulers
which allow set your own validation rule for tags.If true rule is valid, otherwise no. options.cleanRulers = [callback(obj, tagName)]
read(url, {
cleanRulers: [
function(obj, tag) {
if(tag === 'object') {
if(obj.getAttribute('class') === 'BrightcoveExperience') {
return true;
}
}
}
]}, function(err, article, response) {
//...
});
preprocess
which should be a function to check or modify downloaded source before passing it to readability.options.preprocess = callback(source, response, contentType, callback);
read(url, {
preprocess: function(source, response, contentType, callback) {
if (source.length > maxBodySize) {
return callback(new Error('too big'));
}
callback(null, source);
}, function(err, article, response) {
//...
});
The article content of the web page. Return false
if failed.
The article title of the web page. It's may not same to the text in the <title>
tag.
A string containing all the text found on the page
The original html of the web page.
The document of the web page generated by jsdom. You can use it to access the DOM directly(for example, article.document.getElementById('main')
).
response object from request lib. If you need to get current url after all redirect or get some headers it can be useful.
This lib is using jsdom to parser HTML instead of cheerio because some data such as image size and element visibility isn't able to acquire when using cheerio, which will significantly affect the result.
https://github.com/luin/node-readability/graphs/contributors
This code is under the Apache License 2.0. http://www.apache.org/licenses/LICENSE-2.0
FAQs
Turning any web page into a clean view.
The npm package node-readability receives a total of 2,763 weekly downloads. As such, node-readability popularity was classified as popular.
We found that node-readability demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.