linkpreview
Get link (URL) preview
What it is and what it does
linkpreview is a Python library that fetches and parses web page metadata to generate link previews. It gathers data from multiple sources—OpenGraph and Twitter Card meta tags, Microdata, JSON-LD markup, generic HTML tags (h1, p, img), and URL structure—then extracts and normalizes fields like title, description, image, site name, and favicon. The library can either accept pre-fetched HTML content or automatically retrieve it from a URL using requests.
You provide a URL and optionally HTML content, and get back a preview object with standardized fields. It supports custom HTTP headers, preset user-agent profiles (Firefox, Chrome, Googlebot, Twitterbot, etc.), and optional lxml parsing for better performance. The library handles relative URLs by converting them to absolute paths and works with pre-parsed BeautifulSoup objects if you already have one.
Use it for:
- Generate rich link previews in a chat or messaging application by fetching title, description, and image from shared URLs.
- Build a web scraper that collects structured metadata from multiple sites for indexing or comparison.
- Create a social media sharing widget that displays preview cards before users post a link.
- Extract favicon and site name from URLs for bookmark managers or link aggregators.
- Parse and validate OpenGraph metadata on your own site to ensure social media sharing displays correctly.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts preview metadata (title, description, image, site name, favicon) from web URLs by parsing OpenGraph, Twitter Card, Microdata, JSON-LD, and HTML tags.
Yes, if you need link preview extraction and can accept aging maintenance. The library is straightforward, has no known vulnerabilities, and handles the common metadata formats well. Install it if you're building a feature that displays rich link previews; skip it if you need active maintenance or support for cutting-edge HTML5 standards.
Install
linkpreview on PyPI
pip
pip install linkpreviewuv
uv add linkpreviewpoetry
poetry add linkpreviewInstalling linkpreview
Before you install
Low friction install with two common dependencies (requests, beautifulsoup4). Package is aging—last release was 364 days ago—so maintenance responsiveness is unclear, though no recent vulnerabilities are known.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.
Quickstart
from linkpreview import link_preview
preview = link_preview("http://github.com/")
print(preview.title)
print(preview.description)
print(preview.image)
Verify before relying
- Whether the package actively maintains compatibility with Python versions beyond 3.10 or newer Python releases.
- Performance characteristics when parsing large or malformed HTML documents.
- Whether lxml is truly optional or required for acceptable performance in production use.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — requests, beautifulsoup4 |
| Maintenance | aging — 364 days since the last release |
| First released | |
| Downloads | 111,983/month — #12,387 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: linkpreview-0.12.1-py3-none-any.whl
Keywords: link, preview, web, htmlparse, schema.org, opengraph, twittercard, url
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
extructExtracts structured metadata from HTML markup…
permissive · top 15,000 on PyPI
sphinxext-opengraphSphinx extension that automatically generates…
permissive · top 15,000 on PyPI
faviconFetches and parses a website's favicon from its…
permissive · top 15,000 on PyPI
recipe-scrapersExtracts structured recipe data (ingredients,…
permissive · top 15,000 on PyPI
BeautifulSoupBeautiful Soup parses HTML and XML documents…
permissive · top 15,000 on PyPI
twikitTwikit is a Twitter scraper library that lets…
permissive · top 15,000 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
ScweetScrape tweets, profiles, followers, and user…
permissive · top 15,000 on PyPI
parselParsel extracts data from HTML, JSON, and XML…
permissive · top 5,000 on PyPI
sphinx-faviconA Sphinx extension that injects custom favicon…
permissive · top 15,000 on PyPI