Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-readability

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-readability

Turn any web page into a clean view

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
268
decreased by-55.78%
Maintainers
1
Weekly downloads
 
Created
Source

node-readability

Turn any web page into a clean view. It's based on arc90's readability project.

Install

npm install node-readability

Requirements

  • node.js
  • jsdom
  • fetch

Example

readability.read(html [, options], callback)

Where

  • html url or html code.
  • options is an optional options object
  • callback is the callback to run - callback(error, read)

Example

var readability = require('./readability');

// source file is iso-8859-15 but it is converted to utf-8 automatically
readability.read('http://howtonode.org/really-simple-file-uploads', function(err, article) {
  console.log(article.getArticleContent());
});

NB If the file has been marked with charset other than utf-8, it is converted automatically. Charsets such as GBK, GB2312 is also supported via icon.

Options

Possible option values

  • maxRedirects how many redirects allowed, defaults to 10
  • disableRedirects set to true if redirects are not allowed, defaults to false
  • headers optional header fields, in the form of {'Header-Field':'value'}
  • maxResponseLength maximum allowed length for the file, the remainder is cut off. Defaults to Infinity
  • method defaults to GET
  • payload request body
  • disableGzip set to false, to disable content gzipping, needed for Node v0.5.9 which has buggy zlib
  • cookies an array of cookie definitions in the form of ['name=val']
  • cookieJar for sharing cookies between requests, see below
  • outputEncoding
  • disableDecoding set to true to disable automatic charset decoding to utf-8
  • overrideCharset set input encoding
  • asyncDnsLoookup use high performance asynchronous DNS resolution based on c-ares instead of a thread pool calling getaddrinfo(3)
  • timeout set a timeout in ms
  • agent pass-through http.request agent parameter

article

Readability support lazy evaluation by passing readResult to the callback function.

getContent()

Return the article content of the web page. Return false if failed.

getTitle()

Return the article title of the web page.

getHTML()

Return the original html of the web page.

getDocument()

Return the document of the web page generated by jsdom.

TODO

  • Support more readability features
  • Performance optimization

License

This code is under the Apache License 2.0. http://www.apache.org/licenses/LICENSE-2.0

Keywords

FAQs

Package last updated on 28 Mar 2012

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc