Giter VIP home page Giter VIP logo

node-readability's Introduction

node-readability

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

Install

npm install node-readability

Usage

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, article)

Example

var readability = require('node-readability');

readability.read('http://howtonode.org/really-simple-file-uploads', function(err, article) {
  console.log(article.getContent());
});

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 iconv.

Options

node-readability support all the options that fetch support.

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

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

node-readability's People

Contributors

luin avatar btmills avatar brianmaissy avatar rahar avatar haochong avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.