Code Monkey home page Code Monkey logo

iconscraper's Introduction

Icon-Scraper Package Documentation

iconscraper is a Go package that provides a robust solution to get icons from domains.

Icon Sources

Other sources

These aren't currently scraped, but might be of interest:

Usage

Get icons from multiple domains

import "github.com/MeVitae/iconscraper"

config := Config{
    SquareOnly:            true,
    TargetHeight:          128,
    MaxConcurrentRequests: 32,
    AllowSvg:              false,
}

domains := []string{"mevitae.com", "example.com", "gov.uk", "golang.org", "rust-lang.org"}

icons := iconscraper.GetIcons(config, domains)

for domain, icon := range icons {
	fmt.Println("Domain: " + domain + ", Icon URL: " + icon.URL)
}

Handle errors and warnings.

Errors related to decoding images or resources not being found on a web server (but the connection being ok) will be reported as warnings instead of errors.

By default, errors and warnings are only logged to the console. You can handle errors yourself by adding your own channel in the config, for example:

import "github.com/MeVitae/iconscraper"

config := Config{
    SquareOnly:            true,
    TargetHeight:          128,
    MaxConcurrentRequests: 32,
    AllowSvg:              false,
    Errors:                make(chan error),
}

go func(){
    for err := range config.Errors {
        // Handle err
    }
}()

domains := []string{"mevitae.com", "example.com", "gov.uk", "golang.org", "rust-lang.org"}

icons := iconscraper.GetIcons(config, domains)

for domain, icon := range icons {
	fmt.Println("Domain: " + domain + ", Icon URL: " + icon.URL)
}

Warnings can be similarly handled using the Warnings field.

Get icon from a single domain

Icons can be scraped for a single domain using GetIcon. Errors and warnings are handled in the same way.

iconscraper's People

Contributors

jot85 avatar oxygen588 avatar

Stargazers

Bruno Gomes avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.