https://github.com/devnyxie/katsuragi
A Go toolkit offering utilities to efficiently extract favicons, links, descriptions, and titles, with support for LRU caching.
https://github.com/devnyxie/katsuragi
favicons go seo
Last synced: about 1 year ago
JSON representation
A Go toolkit offering utilities to efficiently extract favicons, links, descriptions, and titles, with support for LRU caching.
- Host: GitHub
- URL: https://github.com/devnyxie/katsuragi
- Owner: devnyxie
- License: gpl-3.0
- Created: 2024-07-10T18:17:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-25T23:55:37.000Z (over 1 year ago)
- Last Synced: 2025-04-03T10:51:47.989Z (about 1 year ago)
- Topics: favicons, go, seo
- Language: Go
- Homepage:
- Size: 96.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# katsuragi

[](https://codecov.io/github/devnyxie/katsuragi)
A Go toolkit for web content processing, analysis, and SEO optimization, offering utilities to efficiently extract favicons, links, descriptions and titles.
> [!NOTE]
> Each method is thoroughly tested and optimized for performance, but the package is still in development and may contain unseen bugs. Please don't hesitate to report any issues you encounter!
**Table of Contents**
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Title](#title)
- [Description](#description)
- [Favicons](#favicons)
- [Links/Backlinks](#linksbacklinks)
- [Local Development](#local-development)
- [Testing](#testing)
- [Code Coverage](#code-coverage)
- [License](#license)
# Features
- LRU Caching
- Timeout
- User-Agent
# Installation
```bash
go get github.com/devnyxie/katsuragi
```
# Usage
## Title
The GetTitle() function currently supports the following title meta tags:
- `Title`
- ``
- ``
```go
import (
. "github.com/devnyxie/katsuragi"
)
func main() {
// Create a new fetcher with a timeout of 3 seconds and a cache capacity of 10
fetcher := NewFetcher(
&FetcherProps{
Timeout: 3000, // 3 seconds
CacheCap: 10, // 10 Network Requests will be cached
},
)
defer fetcher.ClearCache()
// Get website's title
title, err := fetcher.GetTitle("https://www.example.com")
}
```
## Description
The GetDescription() function currently supports the following description meta tags:
- ``
- ``
- ``
```go
...
// Get website's description
description, err := fetcher.GetDescription("https://www.example.com")
...
```
## Favicons
The GetFavicons() function currently supports the following favicon meta tags:
- ``
- ``
- ``
> Open Graph image (`og:image`) will be used only if both `og:image:width` and `og:image:height` are present and equal, forming a square image.
```go
...
// Get website's favicons
favicons, err := fetcher.GetFavicons("https://www.example.com")
// [https://www.example.com/favicon.ico, https://www.example.com/favicon.png]
...
```
## Links/Backlinks
The GetLinks() function searches for all `` tags in the HTML document and returns a slice of links.
Options:
- `Url` (required): The URL of the website to fetch.
- `Category` (optional): The category of links to fetch. Possible values are `internal`, `external`, and `all`. Default is `all`.
```go
// Get website's links
links, err := fetcher.GetLinks(GetLinksProps{
Url: "https://www.example.com",
Category: "external",
})
// [https://www.youtube.com/example, https://www.facebook.com/example]
```
# Local Development
## Testing
```bash
go test -v
```
## Code Coverage
```bash
# Generate coverage.out report, generate HTML report from coverage.out, and open the HTML report in the browser:
go test -coverprofile=coverage.out && go tool cover -html=coverage.out -o coverage.html && open coverage.html
```
# License
This project is licensed under the GNU General Public License (GPL). You can find the full text of the license [here](https://www.gnu.org/licenses/gpl-3.0.en.html).