Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js ⚡

License

NotificationsYou must be signed in to change notification settings

jacktuck/unfurl

Repository files navigation

A metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js (>=v8.0.0).

Note: Will not work in the Browser

Travis CICoverage StatusKnown Vulnerabilitiesnpm

ko-fi

The what

Unfurl(spread out from a furled state) will take aurl and someoptions, fetch theurl, extract the metadata we care about and format the result in a sane way. It supports all major metadata providers and expanding it to work for any others should be trivial.

The why

So you know when you link to something on Slack, or Facebook, or Twitter - they typically show a preview of the link. To do so they have crawled the linked website for metadata and enriched the link by providing more context about it. Which usually entails grabbing its title, description and image/player embed.

The how

npm install unfurl.js

unfurl(url [, opts])

url -string


opts -object of:

  • oembed?: boolean - support retrieving oembed metadata
  • timeout? number - req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
  • follow?: number - maximum redirect count. 0 to not follow redirect
  • compress?: boolean - support gzip/deflate content encoding
  • size?: number - maximum response body size in bytes. 0 to disable
  • headers?: Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>> - map of request headers, overrides the defaults

Default headers:

{  'Accept': 'text/html, application/xhtml+xml',  'User-Agent': 'facebookexternalhit'}

import{unfurl}from'unfurl.js'constresult=unfurl('https://github.com/trending')

result is<Promise<Metadata>>

typeMetadata={title?:stringdescription?:stringkeywords?:string[]favicon?:stringauthor?:stringtheme_color?:stringcanonical_url?:stringoEmbed?:OEmbedPhoto|OEmbedVideo|OEmbedLink|OEmbedRichtwitter_card:{card:stringsite?:stringcreator?:stringcreator_id?:stringtitle?:stringdescription?:stringplayers?:{url:stringstream?:stringheight?:numberwidth?:number}[]apps:{iphone:{id:stringname:stringurl:string}ipad:{id:stringname:stringurl:string}googleplay:{id:stringname:stringurl:string}}images:{url:stringalt:string}[]}open_graph:{title:stringtype:stringimages?:{url:stringsecure_url?:stringtype:stringwidth:numberheight:numberalt?:string}[]url?:stringaudio?:{url:stringsecure_url?:stringtype:string}[]description?:stringdeterminer?:stringsite_name?:stringlocale:stringlocale_alt:stringvideos:{url:stringstream?:stringheight?:numberwidth?:numbertags?:string[]}[]article:{published_time?:stringmodified_time?:stringexpiration_time?:stringauthor?:stringsection?:stringtags?:string[]}}}typeOEmbedBase={type:"photo"|"video"|"link"|"rich"version:stringtitle?:stringauthor_name?:stringauthor_url?:stringprovider_name?:stringprovider_url?:stringcache_age?:numberthumbnails?:[{url?:stringwidth?:numberheight?:number}]}typeOEmbedPhoto=OEmbedBase&{type:"photo"url:stringwidth:numberheight:number}typeOEmbedVideo=OEmbedBase&{type:"video"html:stringwidth:numberheight:number}typeOEmbedLink=OEmbedBase&{type:"link"}typeOEmbedRich=OEmbedBase&{type:"rich"html:stringwidth:numberheight:number}

The who 💖

(If you use unfurl.js too feel free toadd your project)

  • vapid/vapid - A template-driven content management system
  • beeman/micro-unfurl - small microservice that unfurls a URL and returns the OpenGraph meta data.
  • probot/unfurl - a GitHub App built with probot that unfurls links on Issues and Pull Request discussions

[8]ページ先頭

©2009-2025 Movatter.jp