# @vipzhichengfork/node-readability

> Turning any web page into a clean view.

Latest version **1.0.5** (published 2020-06-16) · 0 weekly downloads

## Install

```sh
npm install @vipzhichengfork/node-readability
pnpm add @vipzhichengfork/node-readability
yarn add @vipzhichengfork/node-readability
bun add @vipzhichengfork/node-readability
```

Provides the command `readability`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-06-16 |
| First published | 2019-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 2 |
| Dependencies | 4 |
| Unpacked size | 35.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zihua Li |
| Maintainers | vipzhicheng |
| Keywords | readability |

## Links

- npm: https://www.npmjs.com/package/@vipzhichengfork/node-readability
- Repository: https://github.com/vipzhichengfork/readability
- Homepage: https://github.com/luin/node-readability
- Issues: https://github.com/vipzhichengfork/readability/issues
- npm.io page: https://npm.io/package/@vipzhichengfork/node-readability

## Dependencies (4)

- [jsdom](https://npm.io/package/jsdom.md) ^15.2.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [encoding](https://npm.io/package/encoding.md) ~0.1.12
- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Recent versions

- 1.0.5 (latest) — 2020-06-16
- 1.0.4 — 2020-06-16
- 1.0.3 — 2019-11-21
- 1.0.2 — 2019-10-27
- 1.0.1 — 2019-10-27
- 3.0.1 — 2019-10-27

## README

# Readability

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

[![Build Status](https://travis-ci.org/luin/readability.png?branch=master)](https://travis-ci.org/luin/readability)

**CAUTION**

This package is a fork of [node-readability](https://www.npmjs.com/package/node-readability), I just fork it to update old dependencies and do a little fix, maybe later i will drop it to use the original, if the original getting better. 

## Features
1. Optimized for more websites.
2. Supporting HTML5 tags (`article`, `section`) and Microdata API.
3. Focusing on both accuracy and performance. 4x times faster than arc90's version.
3. Supporting encodings such as GBK and GB2312.
4. Converting relative urls to absolute for images and links automatically (Thank [Guillermo Baigorria](https://github.com/gbaygon) & [Tom Sutton](https://github.com/tomsutton1984)).

## Example

[Before](https://raw.githubusercontent.com/luin/node-readability/master/examples/before.png) -> [After](https://raw.githubusercontent.com/luin/node-readability/master/examples/after.png)

## Install

    $ npm install node-readability

Note that from v2.0.0, 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.

## Usage

`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, meta)`

Example
```javascript
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.

## Options

node-readability will pass the options to [request](https://github.com/mikeal/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)]
```javascript
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);
```javascript
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) {
    //...
  });
```


## article object

### content

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

### title

The article title of the web page. It's may not same to the text in the `<title>` tag.

### textBody

A string containing all the text found on the page

### html

The original html of the web page.

### document
The document of the web page generated by jsdom. You can use it to access the DOM directly (for example, `article.document.getElementById('main')`).

## meta object

Response object from request lib. If you need to get current url after all redirect or get some headers it can be useful.

## Why not Cheerio

This lib is using jsdom to parse 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.

## Contributors

https://github.com/luin/node-readability/graphs/contributors

## License

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


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/luin/node-readability/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

---
_Source: https://npm.io/package/@vipzhichengfork/node-readability · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
