Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to grab a logo icon from website URL, programmatically?

I am in the process of creating an activity where I will show the list of website visited with its logo and its alias name chosen by user.

e.g.

  • Recent Websites Visited

    logo1 website1/alias name

    logo2 website2/alias name

    .

    . so no

The question is, (Ref. attached image) How to get website logo displayed on left side of http://?

Like below I want to just grab the icon and save it locally

like image 344
mask Avatar asked May 04 '12 21:05

mask


4 Answers

It's called a favicon, and all you have to do is:

  1. If there's an icon at /favicon.ico, use that.
  2. Otherwise, get the content of the page, and extract the location from <link rel="shortcut icon" href="URL goes here" />. You’ll need to use an HTML parser and find the <link> with a rel of either icon or shortcut icon.
like image 185
Ry- Avatar answered Nov 16 '22 05:11

Ry-


I know I am late but this API will help others

Android doesn't support favicon files. You can fetch favicon but can't show/use it.

But Google provides free API to get favicon in image format.

https://www.google.com/s2/favicons?sz=64&domain_url=microsoft.com

Use Picasso to show icon in imageview.

like image 37
Pritam Pawade Avatar answered Nov 16 '22 04:11

Pritam Pawade


Use this website:

https://besticon-demo.herokuapp.com/allicons.json?url=www.stackoverflow.com

It will find all logos for a website in multiple sizes and return a nice json string with meta data including the url to the icon. You simply replace www.stackoverflow.com with your domain.

The site also has a gui for entering in websites manually if you prefer:

https://besticon-demo.herokuapp.com/

Here is a sample string returned from querying for the stack overflow website:

{
   "url":"www.stackoverflow.com",
   "icons":[
      {
         "url":"http://stackoverflow.com/apple-touch-icon.png",
         "width":158,
         "height":158,
         "format":"png",
         "bytes":3445,
         "error":null,
         "sha1sum":"c78bd457575a3221c6b3d0d17ffb00ffc63d7cd0"
      },
      {
         "url":"http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d",
         "width":32,
         "height":32,
         "format":"ico",
         "bytes":5430,
         "error":null,
         "sha1sum":"4f32ecc8f43d0986b9c6ce9f37999e86c0b829ef"
      },
      {
         "url":"http://stackoverflow.com/favicon.ico",
         "width":32,
         "height":32,
         "format":"ico",
         "bytes":5430,
         "error":null,
         "sha1sum":"4f32ecc8f43d0986b9c6ce9f37999e86c0b829ef"
      }
   ]
}
like image 20
Jack Fairfield Avatar answered Nov 16 '22 03:11

Jack Fairfield


Use this logo.clearbit.com/stackoverflow.com

You can even customize to get particular size and grascaled version

logo.clearbit.com/stackoverflow.com?size=80&greyscale=true

like image 7
Kunal Gupta Avatar answered Nov 16 '22 03:11

Kunal Gupta