{"id":23968,"library":"linkpreview","title":"Linkpreview","description":"Python library to extract link previews (title, description, image, etc.) from URLs. Version 0.12.1. No regular release cadence; final release was 2020.","status":"active","version":"0.12.1","language":"python","source_language":"en","source_url":"https://github.com/miladrahimi/linkpreview","tags":["link-preview","url-preview","metadata","opengraph"],"install":[{"cmd":"pip install linkpreview","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Fetching web pages","package":"requests","optional":false},{"reason":"HTML parsing","package":"lxml","optional":false},{"reason":"HTML parsing (used via lxml)","package":"beautifulsoup4","optional":false}],"imports":[{"note":"get_preview was renamed to link_preview in v0.10.0.","wrong":"from linkpreview import get_preview","symbol":"link_preview","correct":"from linkpreview import link_preview"},{"note":"Class-based API for advanced usage.","symbol":"LinkPreview","correct":"from linkpreview import LinkPreview"}],"quickstart":{"code":"from linkpreview import link_preview\n\nurl = \"https://example.com\"\npreview = link_preview(url)\nprint(preview.title)\nprint(preview.description)\nprint(preview.image)\nprint(preview.force_title)\nprint(preview.force_description)\nprint(preview.force_image)","lang":"python","description":"Get a link preview with title, description, and image. Use the functional API for simplicity."},"warnings":[{"fix":"Replace `get_preview(url)` with `link_preview(url)`.","message":"In v0.10.0, the function `get_preview` was renamed to `link_preview`. Code using `get_preview` will raise AttributeError.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use the functional API `link_preview(url)` for simplicity, or update class usage: `preview = LinkPreview(url); preview.fetch_and_extract()`.","message":"The `LinkPreview` class constructor changed: in older versions, you passed a URL directly; in v0.11+, you must pass a string and then call `fetch_and_extract()`.","severity":"deprecated","affected_versions":">=0.11.0"},{"fix":"Pass a custom headers dictionary when using the class-based API: `LinkPreview(url, headers={'User-Agent': 'Mozilla/5.0'})` or use requests.Session.","message":"The library does not set a User-Agent header by default. Some websites may block requests, returning empty or malformed previews.","severity":"gotcha","affected_versions":"all"},{"fix":"Validate the URL scheme before passing to linkpreview; skip unsupported schemes.","message":"The library does not handle non-HTTP/HTTPS schemes (e.g., ftp://, file://). Attempting to parse such URLs may raise an exception or fail silently.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from linkpreview import link_preview` and call `link_preview(url)`.","cause":"The function `get_preview` was renamed to `link_preview` in v0.10.0.","error":"AttributeError: module 'linkpreview' has no attribute 'get_preview'"},{"fix":"Ensure the URL is accessible (set a User-Agent if needed), or handle the exception gracefully.","cause":"The URL could not be fetched or the page did not contain any meta tags for preview (e.g., no Open Graph, Twitter cards, or schema.org). Also occurs if the request is blocked.","error":"linkpreview.exceptions.LinkPreviewException: No preview data found"},{"fix":"Upgrade to the latest version (0.12.1). For the class-based API, use `LinkPreview(url, headers={'User-Agent': '...'})`. For the functional API, consider using requests.Session to set headers globally.","cause":"The `LinkPreview` class in older versions (<0.11) did not accept `headers` directly. The functional API `link_preview` also does not accept headers.","error":"TypeError: __init__() got an unexpected keyword argument 'headers'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}