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

High-performance metadata scraper

License

NotificationsYou must be signed in to change notification settings

fabon-f/fetch-site-metadata

Repository files navigation

High-performance metadata scraper for Node.js

Features

  • Don't download whole contents to get site metadata.
    • Fetch and parse the content of thehead element only. Interrupt HTTP request when the<body> element starts.
    • Download only first few kilobytes to determine image size (byimage-dimensions package)

Install

npm install fetch-site-metadata

Usage

This package requires Node.js v18 or higher. ESM only.

importfetchSiteMetadatafrom'fetch-site-metadata'awaitfetchSiteMetadata('https://github.com/')// result:{title:'GitHub: Let’s build from here',description:'GitHub is where over 94 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...',icon:'https://github.githubassets.com/favicons/favicon.svg',image:{src:'https://github.githubassets.com/images/modules/site/social-cards/campaign-social.png',width:'1200',height:'630',alt:'GitHub is where over 94 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...'}}

API

fetchSiteMetadata(url: string | URL, options?: Options)

Return value:Promise<Metadata>

Fetch target site and scrape metadata. This function send multiple requests to determine OG image size and other informations by default.

suppressAdditionalRequest option suppress this behavior. WithsuppressAdditionalRequestoption, this function fetches only the specified URL and reduces processing time, but provides only information which can be extracted from the specified page.

You can also pass the options forfetch function.

typeOptions={suppressAdditionalRequest?:boolean}&RequestInittypeImageInfo={src:stringwidth:string|undefinedheight:string|undefinedalt:string|undefined}typeMetadata={title:string|undefineddescription:string|undefinedicon:string|undefinedimage:ImageInfo|undefined}
// example using fetch optionsfetchSiteMetadata('https://example.test',{headers:{'User-Agent':'bot'}})

About

High-performance metadata scraper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp