Skip to content

Commit

Permalink
改用cheerio,弃用jsdom
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanye committed Aug 27, 2013
1 parent 9e93507 commit 379d93e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 743 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
node_modules
.idea
22 changes: 2 additions & 20 deletions README.md
Expand Up @@ -22,8 +22,8 @@ Example

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

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

**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](https://github.com/bnoordhuis/node-iconv).
Expand All @@ -50,24 +50,6 @@ Possible option values
* **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
Expand Down
10 changes: 3 additions & 7 deletions examples/simple.js
@@ -1,12 +1,8 @@
var readability = require('../src/readability')
var readability = require('../src/readability');

// uncoment the following line to print the debug info to console.
// readability.debug(true);


readability.read('http://colorlines.com/archives/2011/08/dispatch_from_angola_faith-based_slavery_in_a_louisiana_prison.html',
function(err, read) {
var dom = read.getDocument();
var html = '<html><head><meta charset="utf-8"><title>'+dom.title+'</title></head><body><h1>'+read.getTitle()+'</h1>'+read.getContent()+'</body></html>';
console.log(html);
readability.read('http://jb.qm120.com/', function (err, $) {
console.log($('body').html());
});
59 changes: 26 additions & 33 deletions package.json
@@ -1,35 +1,28 @@
{
"name": "node-readability",
"version": "0.0.8",
"author": "Zihua Li",
"description": "Turning any web page into a clean view.",
"homepage": "https://github.com/luin/node-readability",
"repository": {
"type": "git",
"url": "git://github.com/luin/node-readability.git"
},
"scripts": {
"test": "mocha -R spec"
},
"main": "./src/readability",
"licenses": [
{
"type": "Apache License 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"dependencies": {
"fetch": "0.3.x",
"jsdom": "0.6.x"
},
"engines": [
"node >=0.6.0"
],
"keywords": [
"readability"
],
"devDependencies": {
"mocha": "~1.8.2",
"should": "~1.2.2"
}
"name": "node-readability",
"version": "0.0.8.1",
"author": "Zihua Li",
"description": "Turning any web page into a clean view.",
"homepage": "https://github.com/luin/node-readability",
"repository": {
"type": "git",
"url": "git://github.com/luin/node-readability.git"
},
"main": "./src/readability",
"licenses": [
{
"type": "Apache License 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"dependencies": {
"fetch": "*",
"cheerio": "*"
},
"engines": [
"node >=0.6.0"
],
"keywords": [
"readability"
]
}

0 comments on commit 379d93e

Please sign in to comment.