-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
1,954 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
unsafe-perm=true | ||
save-prefix=~ | ||
shrinkwrap=false | ||
save=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# metascraper-readability | ||
|
||
[![npm](https://img.shields.io/npm/v/metascraper-readability.svg?style=flat-square)](https://www.npmjs.com/package/metascraper-readability) | ||
[![Dependency Status](https://david-dm.org/microlinkhq/metascraper.svg?path=packages/metascraper-readability&style=flat-square)](https://david-dm.org/microlinkhq/metascraper?path=packages/metascraper-readability) | ||
|
||
> A Readability connector for metascraper | ||
## Install | ||
|
||
```bash | ||
$ npm install metascraper-readability --save | ||
``` | ||
|
||
## License | ||
|
||
**metascraper-readability** © [microlink.io](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/metascraper-readability/blob/master/LICENSE.md) License.<br> | ||
Authored and maintained by microlink.io with help from [contributors](https://github.com/microlinkhq/metascraper-readability/contributors). | ||
|
||
> [microlink.io](https://microlink.io) · GitHub [@microlink.io](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq) |
21 changes: 21 additions & 0 deletions
21
packages/metascraper-readability/__snapshots__/index.js.snap-shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
exports['learnnode.com 1'] = { | ||
"description": "A premium training course to learn to build apps with Node.js, Express, MongoDB, and friends.", | ||
"publisher": "Learn Node", | ||
"author": null, | ||
"title": "Learn Node" | ||
} | ||
|
||
exports['microlink.io 1'] = { | ||
"description": "Extract structured data from any website. Enter an URL, receive information. Get relevant information from any link & easily create beautiful previews.", | ||
"publisher": "Microlink", | ||
"author": null, | ||
"title": "Turns any website into data" | ||
} | ||
|
||
exports['kikobeats.com 1'] = { | ||
"description": "A millennial doing stuff on internet that ships software every day and builds digital products.", | ||
"publisher": "Kikobeats", | ||
"author": "kikobeats", | ||
"title": "Kikobeats" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict' | ||
|
||
const helpers = require('@metascraper/helpers') | ||
const { eq, get, invoke } = require('lodash') | ||
const Readability = require('readability') | ||
const memoizeOne = require('memoize-one') | ||
const { JSDOM } = require('jsdom') | ||
|
||
const memoFn = (newArgs, oldArgs) => eq(newArgs.url, oldArgs.url) | ||
|
||
const readability = opts => { | ||
const dom = new JSDOM(opts) | ||
const reader = new Readability(dom.window.document) | ||
return reader.parse() | ||
} | ||
|
||
const getReadbility = ({ from, to = from }) => | ||
memoizeOne(({ htmlDom, url }) => { | ||
const data = readability(htmlDom.html(), { url }) | ||
const value = get(data, from) | ||
return invoke(helpers, to, value) | ||
}, memoFn) | ||
|
||
module.exports = () => { | ||
return { | ||
description: getReadbility({ from: 'excerpt', to: 'description' }), | ||
publisher: getReadbility({ from: 'siteName', to: 'publisher' }), | ||
author: getReadbility({ from: 'byline', to: 'author' }), | ||
title: getReadbility({ from: 'title' }) | ||
} | ||
} | ||
|
||
module.exports.readability = readability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "metascraper-readability", | ||
"description": "A Readability connector for metascraper", | ||
"homepage": "https://metascraper.js.org", | ||
"version": "4.10.1", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/microlinkhq/metascraper/tree/master/packages/metascraper-readability" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/microlinkhq/metascraper/issues" | ||
}, | ||
"keywords": [ | ||
"metascraper", | ||
"url" | ||
], | ||
"dependencies": { | ||
"@metascraper/helpers": "^4.10.1", | ||
"jsdom": "~14.0.0", | ||
"lodash": "~4.17.11", | ||
"memoize-one": "~5.0.0", | ||
"readability": "github:mozilla/readability" | ||
}, | ||
"devDependencies": { | ||
"metascraper": "latest", | ||
"mocha": "latest", | ||
"nyc": "latest", | ||
"snap-shot": "latest", | ||
"standard": "latest" | ||
}, | ||
"engines": { | ||
"node": ">= 8" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "NODE_PATH=.. TZ=UTC NODE_ENV=test nyc mocha test" | ||
}, | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"metascraper": "^4" | ||
}, | ||
"standard": { | ||
"env": [ | ||
"mocha" | ||
] | ||
} | ||
} |
Oops, something went wrong.