{"id":15069848,"url":"https://github.com/andrejgajdos/link-preview-generator","last_synced_at":"2025-04-13T02:26:12.466Z","repository":{"id":36064066,"uuid":"221217696","full_name":"AndrejGajdos/link-preview-generator","owner":"AndrejGajdos","description":"Get preview data (a title, description, image, domain name) from a url. Library uses puppeteer headless browser to scrape the web site.","archived":false,"fork":false,"pushed_at":"2024-05-03T16:21:18.000Z","size":124,"stargazers_count":265,"open_issues_count":9,"forks_count":66,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-04T11:59:38.094Z","etag":null,"topics":["javascript","link-preview","node","node-js","open-graph","preview","url"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndrejGajdos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-12T12:54:33.000Z","updated_at":"2025-03-31T18:17:51.000Z","dependencies_parsed_at":"2024-06-18T15:36:47.682Z","dependency_job_id":"37c2415c-9837-484a-8d58-8f0325d0ff6b","html_url":"https://github.com/AndrejGajdos/link-preview-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrejGajdos%2Flink-preview-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrejGajdos%2Flink-preview-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrejGajdos%2Flink-preview-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrejGajdos%2Flink-preview-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndrejGajdos","download_url":"https://codeload.github.com/AndrejGajdos/link-preview-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248656296,"owners_count":21140673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","link-preview","node","node-js","open-graph","preview","url"],"created_at":"2024-09-25T01:45:07.356Z","updated_at":"2025-04-13T02:26:12.445Z","avatar_url":"https://github.com/AndrejGajdos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# link-preview-generator\n\n![NPM Downloads](https://img.shields.io/npm/dw/link-preview-generator)\n![NPM License](https://img.shields.io/npm/l/link-preview-generator)\n[![Twitter](https://img.shields.io/twitter/follow/Andrej_Gajdos.svg?style=social\u0026label=@Andrej_Gajdos)](https://twitter.com/Andrej_Gajdos)\n\n\u003e Get preview data (a title, description, image, domain name) from a url. Library uses puppeteer headless browser to scrape the web site.\n\n[BLOG POST](https://andrejgajdos.com/how-to-create-a-link-preview/) and [DEMO](https://link-preview-generator.herokuapp.com/)\n\n## Install\n\n```\n$ npm install link-preview-generator\n```\n\n## Usage\n\n```js\nconst linkPreviewGenerator = require(\"link-preview-generator\");\n\nconst previewData = await linkPreviewGenerator(\n  \"https://www.youtube.com/watch?v=8mqqY2Ji7_g\"\n);\nconsole.log(previewData);\n/*\n{\n  title: 'Kiteboarding: Stylish Backroll in 4 Sessions - Ride with Blake: Vlog 20',\n  description: 'The backroll is a staple in your kiteboarding trick ' +\n    'bag. With a few small adjustments, you can really ' +\n    'improve your style and make this basic your own. ' +\n    'Sessio...',\n  domain: 'youtube.com',\n  img: 'https://i.ytimg.com/vi/8mqqY2Ji7_g/hqdefault.jpg',\n  favicon: 'https://www.youtube.com/s/desktop/d3411c39/img/favicon.ico'\n}\n*/\n```\n\n## API\n\n### linkPreviewGenerator(url, puppeteerArgs?, puppeteerAgent?)\n\nAccepts a `url`, which is scraped and optional parameters `puppeteerArgs` -- browser options and `puppeteerAgent` -- browser user agent.\n\nReturns an object with preview data of `url`.\n\n#### url\n\nType: `string`\n\nScraped url.\n\n#### puppeteerArgs\n\nType: `array`\n\nOptions to set on the Chrome browser.\n\n#### puppeteerAgent\n\nType: `string`\n\nSpecific user agent to use.\n\n## Troubleshooting\nIf you need to deploy this library (Puppeteer) on Heroku, follow [these steps](https://stackoverflow.com/a/55090914/968379).\n\nIf you want to run this library from within a Docker container:\n1. pass the following puppeteer arguments as second argument\n```json\n// Required for Docker version of Puppeteer\n'--no-sandbox',\n'--disable-setuid-sandbox',\n// This will write shared memory files into /tmp instead of /dev/shm,\n// because Docker’s default for /dev/shm is 64MB\n'--disable-dev-shm-usage'\n```\n2. make sure your Docker image has all needed dependencies for headless chrome or just go straight away with [buildkite/puppeteer](https://hub.docker.com/r/buildkite/puppeteer/dockerfile)\n3. done\n\n## License\n\nMIT © [Andrej Gajdos](http://andrejgajdos.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejgajdos%2Flink-preview-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrejgajdos%2Flink-preview-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejgajdos%2Flink-preview-generator/lists"}