Crates.io | meta_fetcher |
lib.rs | meta_fetcher |
version | 0.1.1 |
source | src |
created_at | 2024-04-11 19:42:01.115267 |
updated_at | 2024-04-11 19:46:30.509407 |
description | A simple website metadata fetcher |
homepage | |
repository | https://github.com/sotch-pr35mac/meta-fetcher |
max_upload_size | |
id | 1205262 |
size | 10,472 |
Metadata Fetcher is a utility for grabbing website metadata; useful for tasks like generating link previews. Its built ontop of ureq.
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.
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()));
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.
MIT