2 releases

0.1.1 Apr 11, 2024
0.1.0 Apr 11, 2024

#1595 in Web programming

Download history 10/week @ 2024-07-20 13/week @ 2024-07-27 10/week @ 2024-08-10 26/week @ 2024-08-17 106/week @ 2024-08-24 107/week @ 2024-08-31 81/week @ 2024-09-07 29/week @ 2024-09-14 109/week @ 2024-09-21 64/week @ 2024-09-28 95/week @ 2024-10-05 60/week @ 2024-10-12 37/week @ 2024-10-19 49/week @ 2024-10-26 38/week @ 2024-11-02

199 downloads per month

MIT license

10KB
117 lines

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

Dependencies

~8–15MB
~183K SLoC