meta_fetcher

Crates.iometa_fetcher
lib.rsmeta_fetcher
version0.1.1
sourcesrc
created_at2024-04-11 19:42:01.115267
updated_at2024-04-11 19:46:30.509407
descriptionA simple website metadata fetcher
homepage
repositoryhttps://github.com/sotch-pr35mac/meta-fetcher
max_upload_size
id1205262
size10,472
Preston Wang-Stosur-Bassett (sotch-pr35mac)

documentation

README

Metadata Fetcher

Metadata Fetcher is a utility for grabbing website metadata; useful for tasks like generating link previews. Its built ontop of ureq.

Behavior

Metadata Fetcher first looks for a site's Open Graph Protocol (OGP) metadata and if not found, it looks for the standard HTML metadata. If no metadata is found, it returns None for the missing field. This module also respects a site's robots.txt file.

Usage

use meta_fetcher::fetch_metadata;

// Grab the metadata for some URL
let meta = fetch_metadata("http://example.com").unwrap();

assert_eq!(meta.title, Some("Example Title".to_string()));
assert_eq!(meta.description, Some("Example Description".to_string()));
assert_eq!(meta.image, Some("Image URL".to_string()));

Running Tests

The Makefile specifies two types of tests. make test-ci is the same as running cargo test and will run all tests that do not require network activity to run. make test is the same as running cargo test --features network-tests and will run all tests, including those that require a network connection.

License

MIT

Commit count: 3

cargo fmt