
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
open-graph-scraper-lite
Advanced tools
Javascript scraper module for Open Graph and Twitter Card info
A simple javascript module for scraping Open Graph and Twitter Card info from given HTML. For Node.js usage, we recommend open-graph-scraper
by the same people and can do HTTP requests.
npm install open-graph-scraper-lite --save
const ogs = require('open-graph-scraper');
const options = {
html: `<html><head>
<link rel="icon" type="image/png" href="https://bar.com/foo.png" />
<meta charset="utf-8" />
<meta property="og:description" name="og:description" content="html description example" />
<meta property="og:image" name="og:image" content="https://www.foo.com/bar.jpg" />
<meta property="og:title" name="og:title" content="foobar" />
<meta property="og:type" name="og:type" content="website" />
</head></html>`
};
ogs(options)
.then((data) => {
const { result } = data;
console.log('result:', result);
})
result: {
ogDescription: 'html description example',
ogTitle: 'foobar',
ogType: 'website',
ogImage: [ { url: 'https://www.foo.com/bar.jpg', type: 'jpg' } ],
favicon: 'https://bar.com/foo.png',
charset: 'utf-8',
success: true
}
Name | Info | Default Value | Required |
---|---|---|---|
html | You can pass in an HTML string to run ogs on it. (use without options.url) | x | |
onlyGetOpenGraphInfo | Only fetch open graph info and don't fall back on anything else. | false | |
customMetaTags | Here you can define custom meta tags you want to scrape. | [] |
const ogs = require('open-graph-scraper');
const options = {
html: `<html><head>
<link rel="icon" type="image/png" href="https://bar.com/foo.png" />
<meta charset="utf-8" />
<meta property="og:description" name="og:description" content="html description example" />
<meta property="og:image" name="og:image" content="https://www.foo.com/bar.jpg" />
<meta property="og:title" name="og:title" content="foobar" />
<meta property="og:type" name="og:type" content="website" />
<meta name="hostname" content="github.com">
</head></html>`,
customMetaTags: [{
multiple: false, // is there more than one of these tags on a page (normally this is false)
property: 'hostname', // meta tag name/property attribute
fieldName: 'hostnameMetaTag', // name of the result variable
}],
};
ogs(options)
.then((data) => {
const { result } = data;
console.log('hostnameMetaTag:', result.customMetaTags.hostnameMetaTag); // hostnameMetaTag: github.com
})
2.1.0
charset
fallback. Replace Buffer.from with Uint8Array since body is always htmlFAQs
Javascript scraper module for Open Graph and Twitter Card info
The npm package open-graph-scraper-lite receives a total of 818 weekly downloads. As such, open-graph-scraper-lite popularity was classified as not popular.
We found that open-graph-scraper-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.