{"id":13511725,"url":"https://github.com/luin/readability","last_synced_at":"2025-12-18T07:32:13.142Z","repository":{"id":2852322,"uuid":"3856601","full_name":"luin/readability","owner":"luin","description":"📚 Turn any web page into a clean view","archived":false,"fork":false,"pushed_at":"2021-04-03T15:41:02.000Z","size":3535,"stargazers_count":2484,"open_issues_count":35,"forks_count":313,"subscribers_count":80,"default_branch":"master","last_synced_at":"2024-10-29T23:18:44.558Z","etag":null,"topics":["gbk","instapaper","jsdom","readability"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-28T15:44:51.000Z","updated_at":"2024-10-29T01:39:35.000Z","dependencies_parsed_at":"2022-08-08T16:15:10.957Z","dependency_job_id":null,"html_url":"https://github.com/luin/readability","commit_stats":null,"previous_names":["luin/node-readability"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Freadability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Freadability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Freadability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Freadability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luin","download_url":"https://codeload.github.com/luin/readability/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445667,"owners_count":20939958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gbk","instapaper","jsdom","readability"],"created_at":"2024-08-01T03:01:08.401Z","updated_at":"2025-12-18T07:32:13.076Z","avatar_url":"https://github.com/luin.png","language":"HTML","readme":"# Readability\n\nTurn any web page into a clean view. This module is based on arc90's readability project.\n\n## Features\n1. Optimized for more websites.\n2. Supporting HTML5 tags (`article`, `section`) and Microdata API.\n3. Focusing on both accuracy and performance. 4x times faster than arc90's version.\n3. Supporting encodings such as GBK and GB2312.\n4. Converting relative urls to absolute for images and links automatically (Thank [Guillermo Baigorria](https://github.com/gbaygon) \u0026 [Tom Sutton](https://github.com/tomsutton1984)).\n\n## Example\n\n[Before](https://raw.githubusercontent.com/luin/node-readability/master/examples/before.png) -\u003e [After](https://raw.githubusercontent.com/luin/node-readability/master/examples/after.png)\n\n## Install\n\n    $ npm install node-readability\n\nNote that from v2.0.0, this module only works with Node.js \u003e= 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.\n\n## Usage\n\n`read(html [, options], callback)`\n\nWhere\n\n  * **html** url or html code.\n  * **options** is an optional options object\n  * **callback** is the callback to run - `callback(error, article, meta)`\n\nExample\n```javascript\nvar read = require('node-readability');\n\nread('http://howtonode.org/really-simple-file-uploads', function(err, article, meta) {\n  // Main Article\n  console.log(article.content);\n  // Title\n  console.log(article.title);\n\n  // HTML Source Code\n  console.log(article.html);\n  // DOM\n  console.log(article.document);\n\n  // Response Object from Request Lib\n  console.log(meta);\n\n  // Close article to clean up jsdom and prevent leaks\n  article.close();\n});\n```\n**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.\n\n## Options\n\nnode-readability will pass the options to [request](https://github.com/mikeal/request) directly.\nSee request lib to view all available options.\n\nnode-readability has two additional options:\n\n- `cleanRulers` which allow set your own validation rule for tags.\n\nIf true rule is valid, otherwise no.\noptions.cleanRulers = [callback(obj, tagName)]\n```javascript\nread(url, {\n  cleanRulers: [\n    function(obj, tag) {\n      if(tag === 'object') {\n        if(obj.getAttribute('class') === 'BrightcoveExperience') {\n          return true;\n        }\n      }\n    }\n  ]}, function(err, article, response) {\n    //...\n  });\n```\n\n- `preprocess` which should be a function to check or modify downloaded source before passing it to readability.\n\noptions.preprocess = callback(source, response, contentType, callback);\n```javascript\nread(url, {\n    preprocess: function(source, response, contentType, callback) {\n      if (source.length \u003e maxBodySize) {\n        return callback(new Error('too big'));\n      }\n      callback(null, source);\n    }\n  }, function(err, article, response) {\n    //...\n  });\n```\n\n\n## article object\n\n### content\n\nThe article content of the web page. Return `false` if failed.\n\n### title\n\nThe article title of the web page. It's may not same to the text in the `\u003ctitle\u003e` tag.\n\n### textBody\n\nA string containing all the text found on the page\n\n### html\n\nThe original html of the web page.\n\n### document\nThe document of the web page generated by jsdom. You can use it to access the DOM directly (for example, `article.document.getElementById('main')`).\n\n## meta object\n\nResponse object from request lib. If you need to get current url after all redirect or get some headers it can be useful.\n\n## Why not Cheerio\n\nThis 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.\n\n## Contributors\n\nhttps://github.com/luin/node-readability/graphs/contributors\n\n## License\n\nThis code is under the Apache License 2.0.  http://www.apache.org/licenses/LICENSE-2.0\n","funding_links":[],"categories":["HTML","others","工具"],"sub_categories":["调试"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Freadability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluin%2Freadability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Freadability/lists"}