2.0.3-sync.2 • Published 6 years ago

sync-summaly v2.0.3-sync.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

summaly

NPM

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

PropertyTypeDescriptionDefault
followRedirectsbooleanWhether follow redirectstrue
pluginsplugin[] (see below)Custom pluginsnull

Plugin

interface IPlugin {
	test: (url: URL.Url) => boolean;
	summarize: (url: URL.Url) => Summary;
}

Returns

A Promise of an Object that contains properties below:

PropertyTypeDescription
descriptionstringThe description of the web page
iconstringThe url of the icon of the web page
sitenamestringThe name of the web site
thumbnailstringThe url of the thumbnail of the web page
titlestringThe title of the web page
urlstringThe 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

MIT