
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
metadata-fetch
Advanced tools
This package is used to fetch the metadata of given url or site with help of cheerio.
URL Metadata Fetcher This Node.js module fetches and extracts metadata from a given URL using Cheerio. The extracted metadata includes Open Graph tags, keywords, and the canonical URL.
Table of Contents Installation Usage Functions Example Error Handling
Installation To use this module, you need to have Node.js and npm installed. You can install the required dependencies by running:
bash Copy code npm install cheerio Usage Import the module and call the getMetadata function with a URL as an argument.
javascript Copy code import { getMetadata } from './path/to/module';
// Example URL const url = 'https://example.com';
getMetadata(url).then(metadata => { console.log(metadata); }); Functions getMetadata(url: string) Fetches the metadata from the provided URL.
Parameters:
url (string): The URL from which to fetch metadata. Returns:
An object containing the metadata or an error message. Metadata Object Structure json Copy code { "title": "Open Graph title", "description": "Open Graph description", "image": "Open Graph image URL", "url": "Open Graph URL", "keywords": "Page keywords", "canonical": "Canonical URL" } Error Object Structure json Copy code { "error": "Error message" } Example javascript Copy code import { getMetadata } from './path/to/module';
const url = 'https://example.com';
getMetadata(url).then(metadata => { if (metadata.error) { console.error(metadata.error); } else { console.log(metadata); } }); Error Handling The getMetadata function handles errors gracefully and returns an error message in the following cases:
If the URL is not provided. If the URL is not valid. If the fetch request fails. If an error occurs during the extraction of metadata.
FAQs
This package is used to fetch the metadata of given url or site with help of cheerio.
The npm package metadata-fetch receives a total of 0 weekly downloads. As such, metadata-fetch popularity was classified as not popular.
We found that metadata-fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.