Overview
This node fetches preview information from a given URL. It extracts metadata such as the page title, description, media type, content type, favicons, images, and videos associated with the URL. This is useful for scenarios like generating link previews in chat applications, summarizing URLs in reports, or enriching data with website metadata.
For example, when a user inputs a URL to a news article, the node can retrieve the article's title, description, and main images to display a rich preview without loading the entire webpage.
Properties
| Name | Meaning |
|---|---|
| URL | The web address to fetch preview information from. Must be a valid HTTP or HTTPS URL. |
| Options | Collection of optional settings: • Timeout (Seconds): Maximum wait time for fetching preview (default 10 seconds). • Follow Redirects: Whether to follow HTTP redirects when fetching the preview (true or false). |
Output
The node outputs an array of JSON objects, each containing preview information for the corresponding input URL. Each output JSON object has the following structure:
url: The final resolved URL after any redirects.title: Sanitized title of the webpage.description: Sanitized description or summary of the webpage.mediaType: Type of media detected (e.g., "website", "video").contentType: Content MIME type of the resource.favicons: Array of sanitized favicon URLs.images: Array of sanitized image URLs found on the page.videos: Array of sanitized video URLs found on the page.
All textual fields are sanitized to remove potentially unsafe HTML tags and attributes, ensuring safe usage downstream.
Dependencies
- Uses an external library to fetch and parse link preview metadata.
- Utilizes a DOM sanitization library to clean HTML content.
- Requires network access to fetch the URL content.
- No special credentials or API keys are needed.
Troubleshooting
- Invalid URL format: If the provided URL is malformed or missing a protocol, the node will throw an error indicating invalid URL format. Ensure URLs start with
http://orhttps://. - Timeouts: If the preview fetching exceeds the specified timeout, the operation may fail. Increase the timeout option if necessary.
- Redirect handling: If the target URL redirects and the "Follow Redirects" option is disabled, the node may fail to retrieve preview data.
- Unknown errors: Generic errors during fetching or parsing will result in an "Unknown error occurred" message. Enabling "Continue On Fail" allows processing subsequent items despite errors.
Links and References
- link-preview-js GitHub repository - underlying library used for fetching preview data.
- DOMPurify documentation - library used for sanitizing HTML content.