2.0.3-sync.2 • Published 6 years ago
sync-summaly v2.0.3-sync.2
summaly
Get any web page's summary synchronously. Try it out
❕❕ NOTICE ❕❕
This is synchronized package.
DON'T USE THIS PACKAGE without where you had better need to write synchronously in your product app.
It is more preferable to REWRITE YOUR CODE Asynchronously with USING the FOLLOWING package.
これは同期化されたパッケージです。
製品のアプリケーションで同期的に書く必要に迫られている場所を除き、このパッケージを利用しないでください。
以下のパッケージを利用しながら、非***同期的*にコードを書き換える**ことが望ましいです。
https://github.com/syuilo/summaly
Installation
$ npm install sync-summaly
Usage
summaly(url[, opts])
Options
Property | Type | Description | Default |
---|---|---|---|
followRedirects | boolean | Whether follow redirects | true |
plugins | plugin[] (see below) | Custom plugins | null |
Plugin
interface IPlugin {
test: (url: URL.Url) => boolean;
summarize: (url: URL.Url) => Summary;
}
Returns
A Promise of an Object that contains properties below:
Property | Type | Description |
---|---|---|
description | string | The description of the web page |
icon | string | The url of the icon of the web page |
sitename | string | The name of the web site |
thumbnail | string | The url of the thumbnail of the web page |
title | string | The title of the web page |
url | string | The url of the web page |
Example
Node.js
const summaly = require('sync-summaly').default
const summary = summaly('https://dic.pixiv.net/a/%E3%82%AF%E3%83%AC%E3%82%A4%E3%82%B8%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%86%E3%83%83%E3%83%88');
console.log(summary);
TypeScript
import summaly from 'sync-summaly';
const summary = summaly('https://dic.pixiv.net/a/%E3%82%AF%E3%83%AC%E3%82%A4%E3%82%B8%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%86%E3%83%83%E3%83%88');
console.log(summary);
Result
// will be...
{
title: 'クレイジーカルテット',
icon: 'https://dic.pixiv.net/favicon.ico',
description: '「クレイジーカルテット」とは、東方Projectに登場するフランドール・スカーレット、古明地こいし、封獣ぬえ、鬼人正邪の四名による二次創作グループである。',
thumbnail: 'https://i.pximg.net/c/150x150/img-master/img/2014/12/05/19/15/18/47411920_p0_master1200.jpg',
sitename: 'ピクシブ百科事典',
url: 'https://dic.pixiv.net/a/%E3%82%AF%E3%83%AC%E3%82%A4%E3%82%B8%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%86%E3%83%83%E3%83%88'
}
Testing
npm run test
License
2.0.3-sync.2
6 years ago
2.0.3-sync.1
6 years ago