open-graph-scraper
Advanced tools
Comparing version 6.4.0 to 6.5.0
# Change Log | ||
## 6.5.0 | ||
- Adding support for JSON LD | ||
- Adding support for `og:image:alt`, `twitterAccount`, `fbAppId` and extra og tags for `music` and `video` | ||
- Fixing jsdoc param name | ||
- Updating dependencies | ||
## 6.4.0 | ||
@@ -4,0 +11,0 @@ |
@@ -10,3 +10,3 @@ import type { OpenGraphScraperOptions, OgObject } from './lib/types'; | ||
* @param {object} [options.fetchOptions] - Sets the options used by fetch for the http requests | ||
* @param {object} [options.validatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {object} [options.urlValidatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {string[]} [options.blacklist] - Pass in an array of sites you don't want ogs to run on. | ||
@@ -13,0 +13,0 @@ * @param {string} [options.html] - You can pass in an HTML string to run ogs on it. (use without options.url) |
@@ -16,3 +16,3 @@ "use strict"; | ||
* @param {object} [options.fetchOptions] - Sets the options used by fetch for the http requests | ||
* @param {object} [options.validatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {object} [options.urlValidatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {string[]} [options.blacklist] - Pass in an array of sites you don't want ogs to run on. | ||
@@ -19,0 +19,0 @@ * @param {string} [options.html] - You can pass in an HTML string to run ogs on it. (use without options.url) |
@@ -59,2 +59,7 @@ "use strict"; | ||
ogObject = (0, fallback_1.default)(ogObject, options, $, body); | ||
$('script').each((index, script) => { | ||
if (script.attribs.type && script.attribs.type === 'application/ld+json') { | ||
ogObject.jsonLD = JSON.parse($(script).text()); | ||
} | ||
}); | ||
} | ||
@@ -61,0 +66,0 @@ return ogObject; |
@@ -26,2 +26,7 @@ "use strict"; | ||
{ | ||
multiple: false, | ||
property: 'og:website', | ||
fieldName: 'ogWebsite', | ||
}, | ||
{ | ||
multiple: true, | ||
@@ -38,2 +43,7 @@ property: 'og:image', | ||
multiple: true, | ||
property: 'og:image:alt', | ||
fieldName: 'ogImageAlt', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:image:secure_url', | ||
@@ -164,2 +174,17 @@ fieldName: 'ogImageSecureURL', | ||
multiple: true, | ||
property: 'og:movie', | ||
fieldName: 'ogMovie', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:episode', | ||
fieldName: 'ogEpisode', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:actor', | ||
fieldName: 'ogVideoActor', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:actor:id', | ||
@@ -170,2 +195,37 @@ fieldName: 'ogVideoActorId', | ||
multiple: true, | ||
property: 'og:video:actor:role', | ||
fieldName: 'ogVideoActorRole', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:director', | ||
fieldName: 'ogVideoDirector', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:writer', | ||
fieldName: 'ogVideoWriter', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:duration', | ||
fieldName: 'ogVideoDuration', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:release_date', | ||
fieldName: 'ogVideoReleaseDate', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:Tag', | ||
fieldName: 'ogVideoTag', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:series', | ||
fieldName: 'ogVideoSeries', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:width', | ||
@@ -185,2 +245,12 @@ fieldName: 'ogVideoWidth', | ||
{ | ||
multiple: true, | ||
property: 'og:video:tv_show', | ||
fieldName: 'ogVideoTvShow', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'og:video:other', | ||
fieldName: 'ogVideoOther', | ||
}, | ||
{ | ||
multiple: false, | ||
@@ -217,2 +287,7 @@ property: 'twitter:card', | ||
multiple: false, | ||
property: 'twitter:account', | ||
fieldName: 'twitterAccount', | ||
}, | ||
{ | ||
multiple: false, | ||
property: 'twitter:title', | ||
@@ -323,2 +398,7 @@ fieldName: 'twitterTitle', | ||
multiple: true, | ||
property: 'music:playlist', | ||
fieldName: 'musicPlaylist', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'music:song', | ||
@@ -359,2 +439,7 @@ fieldName: 'musicSongProperty', | ||
multiple: true, | ||
property: 'music:radio_station', | ||
fieldName: 'musicRadioStation', | ||
}, | ||
{ | ||
multiple: true, | ||
property: 'music:creator', | ||
@@ -863,3 +948,8 @@ fieldName: 'musicCreator', | ||
}, | ||
{ | ||
multiple: false, | ||
property: 'fb:app_id', | ||
fieldName: 'fbAppId', | ||
}, | ||
]; | ||
exports.default = fields; |
@@ -31,2 +31,3 @@ "use strict"; | ||
width: item[1], | ||
alt: item[4], | ||
}); | ||
@@ -83,3 +84,4 @@ const mediaSorter = (a, b) => { | ||
|| ogObject.ogImageHeight | ||
|| ogObject.ogImageType) { | ||
|| ogObject.ogImageType | ||
|| ogObject.ogImageAlt) { | ||
ogObject.ogImageSecureURL = ogObject.ogImageSecureURL ? ogObject.ogImageSecureURL : []; | ||
@@ -96,5 +98,6 @@ ogObject.ogImageURL = ogObject.ogImageURL ? ogObject.ogImageURL : []; | ||
ogObject.ogImageType = ogObject.ogImageType ? ogObject.ogImageType : []; | ||
ogObject.ogImageAlt = ogObject.ogImageAlt ? ogObject.ogImageAlt : []; | ||
} | ||
// format images and limit to 10 | ||
const ogImages = zip(ogObject.ogImageProperty, ogObject.ogImageWidth, ogObject.ogImageHeight, ogObject.ogImageType) | ||
const ogImages = zip(ogObject.ogImageProperty, ogObject.ogImageWidth, ogObject.ogImageHeight, ogObject.ogImageType, ogObject.ogImageAlt) | ||
.map(mediaMapper) | ||
@@ -101,0 +104,0 @@ .filter((value) => value.url !== undefined && value.url !== '') |
@@ -79,2 +79,3 @@ import type { RequestInit } from 'undici'; | ||
width?: number; | ||
alt?: string; | ||
}; | ||
@@ -163,2 +164,4 @@ export type VideoObject = { | ||
favicon?: string; | ||
fbAppId?: string; | ||
jsonLD?: object; | ||
modifiedTime?: string; | ||
@@ -172,2 +175,4 @@ musicAlbum?: string; | ||
musicMusician?: string; | ||
musicPlaylist?: string; | ||
musicRadioStation?: string; | ||
musicReleaseDate?: string; | ||
@@ -194,3 +199,5 @@ musicSong?: MusicSongObject[]; | ||
ogDeterminer?: string; | ||
ogEpisode?: string; | ||
ogImage?: ImageObject[]; | ||
ogImageAlt?: string | string[] | null[]; | ||
ogImageHeight?: string | string[] | null[]; | ||
@@ -205,2 +212,3 @@ ogImageProperty?: string | string[] | null[]; | ||
ogLogo?: string; | ||
ogMovie?: string; | ||
ogPriceAmount?: string; | ||
@@ -218,8 +226,19 @@ ogPriceCurrency?: string; | ||
ogVideo?: VideoObject[]; | ||
ogVideoActor?: string; | ||
ogVideoActorId?: string; | ||
ogVideoActorRole?: string; | ||
ogVideoDirector?: string; | ||
ogVideoDuration?: string; | ||
ogVideoHeight?: string | string[] | null[]; | ||
ogVideoOther?: string; | ||
ogVideoProperty?: string | string[] | null[]; | ||
ogVideoReleaseDate?: string; | ||
ogVideoSecureURL?: string; | ||
ogVideoSeries?: string; | ||
ogVideoTag?: string; | ||
ogVideoTvShow?: string; | ||
ogVideoType?: string | string[] | null[]; | ||
ogVideoWidth?: string | string[] | null[]; | ||
ogVideoWriter?: string; | ||
ogWebsite?: string; | ||
placeLocationLatitude?: string; | ||
@@ -248,2 +267,3 @@ placeLocationLongitude?: string; | ||
success?: boolean; | ||
twitterAccount?: string; | ||
twitterAppIdGooglePlay?: string; | ||
@@ -250,0 +270,0 @@ twitterAppIdiPad?: string; |
@@ -16,3 +16,3 @@ /* eslint-disable max-len, import/no-import-module-exports */ | ||
* @param {object} [options.fetchOptions] - Sets the options used by fetch for the http requests | ||
* @param {object} [options.validatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {object} [options.urlValidatorSettings] - Sets the options used by validator.js for testing the URL | ||
* @param {string[]} [options.blacklist] - Pass in an array of sites you don't want ogs to run on. | ||
@@ -19,0 +19,0 @@ * @param {string} [options.html] - You can pass in an HTML string to run ogs on it. (use without options.url) |
{ | ||
"name": "open-graph-scraper", | ||
"description": "Node.js scraper module for Open Graph and Twitter Card info", | ||
"version": "6.4.0", | ||
"version": "6.5.0", | ||
"license": "MIT", | ||
@@ -31,3 +31,3 @@ "main": "./dist/index.js", | ||
"iconv-lite": "^0.6.3", | ||
"undici": "^6.6.2", | ||
"undici": "^6.7.0", | ||
"validator": "^13.11.0" | ||
@@ -41,14 +41,14 @@ }, | ||
"devDependencies": { | ||
"@snyk/protect": "^1.1279.0", | ||
"@snyk/protect": "^1.1281.0", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^18.19.15", | ||
"@types/node": "^18.19.21", | ||
"@types/validator": "^13.11.9", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"@typescript-eslint/eslint-plugin": "^7.1.0", | ||
"@typescript-eslint/parser": "^7.1.0", | ||
"chai": "^4.4.1", | ||
"eslint": "^8.56.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^17.1.0", | ||
"eslint-config-airbnb-typescript": "^18.0.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-mocha": "^10.2.0", | ||
"eslint-plugin-mocha": "^10.3.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
@@ -69,2 +69,3 @@ "mocha": "^10.3.0", | ||
"dublin core", | ||
"json ld", | ||
"meta tags", | ||
@@ -71,0 +72,0 @@ "metadata", |
@@ -6,5 +6,5 @@ # openGraphScraper | ||
A simple node module(with TypeScript declarations) for scraping Open Graph and Twitter Card info off a site. | ||
A simple node module(with TypeScript declarations) for scraping Open Graph and Twitter Card and other metadata off a site. | ||
Note: `open-graph-scraper` doesn't support browser usage at this time. | ||
Note: `open-graph-scraper` doesn't support browser usage at this time but you can use `open-graph-scraper-lite` if you already have the `HTML` and can't use Node's [Fetch API](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch). | ||
@@ -11,0 +11,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95356
2311
Updatedundici@^6.7.0