2021-01-29 12:23:15 +00:00
|
|
|
# site_icons
|
|
|
|
|
2021-01-29 16:26:04 +00:00
|
|
|
[![Crates.io](https://img.shields.io/crates/v/site_icons.svg)](https://crates.io/crates/site_icons)
|
|
|
|
[![Documentation](https://docs.rs/site_icons/badge.svg)](https://docs.rs/site_icons/)
|
|
|
|
![GitHub Sponsors](https://img.shields.io/github/sponsors/samdenty?style=social)
|
|
|
|
|
|
|
|
An efficient website icon scraper for rust or command line usage.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2021-01-29 16:35:42 +00:00
|
|
|
- Super fast!
|
2021-01-29 16:39:45 +00:00
|
|
|
- Partially downloads images to find the sizes
|
2021-01-29 16:35:42 +00:00
|
|
|
- Can extract a site logo `<img>` using a weighing system
|
2021-01-29 16:37:33 +00:00
|
|
|
- Works with inline-data URIs (and automatically converts `<svg>` to them)
|
2021-01-29 16:26:04 +00:00
|
|
|
- Supports WASM (and cloudflare workers)
|
|
|
|
|
|
|
|
### Command line usage
|
|
|
|
|
2023-01-03 18:05:03 +00:00
|
|
|
First install the binary:
|
|
|
|
|
|
|
|
```
|
|
|
|
cargo install site_icons
|
|
|
|
```
|
|
|
|
|
|
|
|
then run either:
|
2021-01-29 16:26:04 +00:00
|
|
|
|
2023-01-03 17:49:19 +00:00
|
|
|
<details open>
|
2023-01-03 18:05:47 +00:00
|
|
|
<summary>For text output:</summary>
|
2023-01-03 18:00:23 +00:00
|
|
|
|
|
|
|
<blockquote>
|
2023-01-03 17:56:11 +00:00
|
|
|
|
2023-01-03 18:08:00 +00:00
|
|
|
Command:
|
|
|
|
|
2023-01-03 18:03:16 +00:00
|
|
|
```bash
|
2023-01-03 18:08:00 +00:00
|
|
|
site-icons https://github.com
|
|
|
|
```
|
2023-01-03 17:56:11 +00:00
|
|
|
|
2023-01-03 18:08:00 +00:00
|
|
|
Output:
|
|
|
|
|
|
|
|
```
|
2023-01-03 17:49:19 +00:00
|
|
|
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/apple-touch-icon-180x180.png app_icon png 180x180
|
2021-01-29 16:26:04 +00:00
|
|
|
```
|
|
|
|
|
2023-01-03 17:56:11 +00:00
|
|
|
</blockquote>
|
|
|
|
|
2023-01-03 17:49:19 +00:00
|
|
|
</details>
|
|
|
|
|
|
|
|
<details open>
|
2023-01-03 18:05:32 +00:00
|
|
|
<summary>For JSON output:</summary>
|
2023-01-03 18:00:23 +00:00
|
|
|
|
|
|
|
<blockquote>
|
2023-01-03 17:56:11 +00:00
|
|
|
|
2023-01-03 18:08:00 +00:00
|
|
|
Command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
site-icons https://reactjs.org --json
|
|
|
|
```
|
|
|
|
|
|
|
|
Output:
|
2023-01-03 17:56:11 +00:00
|
|
|
|
2023-01-03 18:08:00 +00:00
|
|
|
```json
|
2023-01-03 17:36:38 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"url": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0xMS41IC0xMC4yMzE3NCAyMyAyMC40NjM0OCI+CiAgPHRpdGxlPlJlYWN0IExvZ288L3RpdGxlPgogIDxjaXJjbGUgY3g9IjAiIGN5PSIwIiByPSIyLjA1IiBmaWxsPSIjNjFkYWZiIi8+CiAgPGcgc3Ryb2tlPSIjNjFkYWZiIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIi8+CiAgICA8ZWxsaXBzZSByeD0iMTEiIHJ5PSI0LjIiIHRyYW5zZm9ybT0icm90YXRlKDYwKSIvPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIiB0cmFuc2Zvcm09InJvdGF0ZSgxMjApIi8+CiAgPC9nPgo8L3N2Zz4K",
|
|
|
|
"headers": {},
|
|
|
|
"kind": "site_logo",
|
|
|
|
"type": "svg",
|
|
|
|
"size": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "https://reactjs.org/icons/icon-512x512.png?v=f4d46f030265b4c48a05c999b8d93791",
|
|
|
|
"headers": {},
|
|
|
|
"kind": "app_icon",
|
|
|
|
"type": "png",
|
|
|
|
"size": "512x512"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "https://reactjs.org/favicon.ico",
|
|
|
|
"headers": {},
|
|
|
|
"kind": "site_favicon",
|
|
|
|
"type": "ico",
|
|
|
|
"sizes": ["64x64", "32x32", "24x24", "16x16"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "https://reactjs.org/favicon-32x32.png?v=f4d46f030265b4c48a05c999b8d93791",
|
|
|
|
"headers": {},
|
|
|
|
"kind": "site_favicon",
|
|
|
|
"type": "png",
|
|
|
|
"size": "32x32"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2023-01-03 17:56:11 +00:00
|
|
|
</blockquote>
|
|
|
|
|
2023-01-03 17:36:38 +00:00
|
|
|
</details>
|
|
|
|
|
2021-01-29 12:23:15 +00:00
|
|
|
### Sources
|
|
|
|
|
2023-01-03 17:31:13 +00:00
|
|
|
- HTML favicon tag (or looking for default `/favicon.svg` / `/favicon.ico`)
|
2021-01-29 12:23:15 +00:00
|
|
|
- [Web app manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) [`icons`](https://developer.mozilla.org/en-US/docs/Web/Manifest/icons) field
|
|
|
|
- `<img>` tags on the page, directly inside the header OR with a `src|alt|class` containing the text "logo"
|
|
|
|
|
|
|
|
## Running locally
|
|
|
|
|
|
|
|
```bash
|
2023-01-03 17:30:42 +00:00
|
|
|
git clone https://github.com/samdenty/site_icons
|
|
|
|
cd site_icons
|
|
|
|
cargo run https://github.com
|
2021-01-29 12:23:15 +00:00
|
|
|
```
|