A fork of the site-icons crate that's Sync (failed experiment)
This repository has been archived on 2025-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
2023-01-03 15:49:39 +00:00
src cleanup 2023-01-03 15:49:39 +00:00
.gitignore initial commit 2021-01-29 12:23:15 +00:00
.rustfmt.toml initial commit 2021-01-29 12:23:15 +00:00
Cargo.lock fix: update docs 2023-01-03 14:24:47 +00:00
Cargo.toml fix: update docs 2023-01-03 14:24:47 +00:00
Makefile.toml fix 2021-01-30 19:12:13 +00:00
README.md fix: update docs 2023-01-03 14:24:47 +00:00

site_icons

Crates.io Documentation GitHub Sponsors

An efficient website icon scraper for rust or command line usage.

Features

  • Super fast!
  • Partially downloads images to find the sizes
  • Can extract a site logo <img> using a weighing system
  • Works with inline-data URIs (and automatically converts <svg> to them)
  • Supports WASM (and cloudflare workers)

Command line usage

cargo install site_icons

site-icons https://github.com
# https://github.githubassets.com/favicons/favicon.svg site_favicon svg
# https://github.githubassets.com/app-icon-512.png app_icon png 512x512
# https://github.githubassets.com/app-icon-192.png app_icon png 192x192
# https://github.githubassets.com/apple-touch-icon-180x180.png app_icon png 180x180

Rust usage

use site_icons::SiteIcons;

let mut icons = SiteIcons::new();
// scrape the icons from a url
let entries = icons.load_website("https://github.com", false).await?;

// entries are sorted from highest to lowest resolution
for icon in entries {
  println!("{:?}", icon)
}

Sources

  • HTML favicon tag (or looking for default /favicon.ico)
  • Web app manifest icons field
  • <img> tags on the page, directly inside the header OR with a src|alt|class containing the text "logo"

Running locally

Install cargo make and then:

cargo make run https://github.com