html-meta-scraper

Crates.iohtml-meta-scraper
lib.rshtml-meta-scraper
version0.2.0
created_at2025-04-28 04:10:51.085585+00
updated_at2025-08-01 16:42:28.811923+00
descriptionScrape and extract metadata like title, description, images, and favicon from HTML documents.
homepage
repositoryhttps://github.com/46ki75/html-meta-scraper
max_upload_size
id1651781
size39,159
Ikuma Yamashita (46ki75)

documentation

https://docs.rs/html-meta-scraper

README

html-meta-scraper

Scrape and extract metadata like title, description, images, and favicon from HTML documents.

Features

  • Extract <title>, OGP metadata (og:title, og:description, og:image)
  • Extract Twitter Card metadata (twitter:title, twitter:description, twitter:image)
  • Extract favicon (<link rel="icon" href="...">)
  • Prioritized fallback (e.g., og:titletwitter:title<title>)

Installation

Add this to your Cargo.toml:

[dependencies]
html-meta-scraper = "0.1.0"

Example

use html_meta_scraper::MetaScraper;

let html = r#"
    <html>
        <head>
            <meta property="og:title" content="Example Title" />
            <meta name="twitter:description" content="Example Description" />
            <link rel="icon" href="/favicon.ico" />
        </head>
    </html>
"#;

let scraper = MetaScraper::new(html);

assert_eq!(scraper.title(), Some("Example Title".to_string()));
assert_eq!(scraper.description(), Some("Example Description".to_string()));
assert_eq!(scraper.favicon(), Some("/favicon.ico".to_string()));

API Overview

Method Description
title() Retrieves page title (og:titletwitter:title<title>)
description() Retrieves page description (og:descriptiontwitter:descriptiondescription)
image() Retrieves page image URL (og:imagetwitter:image)
favicon() Retrieves favicon URL (<link rel="icon">)
lang() Retrieves language (<html lang="en">)
extract_* methods Low-level methods to extract specific metadata
Commit count: 17

cargo fmt