https://github.com/gri38/hyperlink_preview
Small visual preview and brief description of a http link: this library gets the data.
https://github.com/gri38/hyperlink_preview
hyperlink og-parser ogp ogp-image ogp-meta opengraph opengraph-data opengraph-parser opengraph-tags preview
Last synced: 3 days ago
JSON representation
Small visual preview and brief description of a http link: this library gets the data.
- Host: GitHub
- URL: https://github.com/gri38/hyperlink_preview
- Owner: gri38
- License: mit
- Created: 2022-01-23T16:41:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-24T10:10:36.000Z (almost 4 years ago)
- Last Synced: 2025-09-25T14:17:03.792Z (7 months ago)
- Topics: hyperlink, og-parser, ogp, ogp-image, ogp-meta, opengraph, opengraph-data, opengraph-parser, opengraph-tags, preview
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://hits.dwyl.com/gri38/hyperlink_preview)  
# hyperlink_preview
## Purpose
Hyperlink_preview allows getting data needed to display a small visual preview of a http link.
It searches deeper than only ` 50px.
For the sake of efficiency:
- **read only bytes necessary** to know the dimensions of the images (not the whole image)
- **parallelized requests** to all the images
However, if the target link contains a lot of pictures, it can take a while (one to several seconds) to do all the requests. A hyperlink preview may need to be displayed quickly (for instance: on mouse hover). In that case:
### Get all data except image first, then image
```python
import hyperlink_preview as HLP
hlp = HLP.HyperLinkPreview(url="https://en.wikipedia.org/wiki/Your_Name")
if hlp.is_valid:
preview_data = hlp.get_data(wait_for_imgs=False)
# returns as soon as the data are fetched, but don't wait to "parse" all images tags if needed.
# it allows you to display a spinner as link preview image (or anything else to keep your user waiting).
# ... later you can get the remaining image data if needed:
if preview_data["image"] is None:
preview_data = hlp.get_data(wait_for_imgs=True)
```