Any way to capture a logo icon from a website URL programmatically?

I am engaged in creating activity, where I will show a list of visited websites with its logo and its nickname selected by the user.

eg.

  • Recent Website Visits

    logo1 website1 / alias

    logo2 website2 / alias

    .

    . therefore no

The question is (attached image) How to get the site logo displayed on the left side of http: //?

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

+5
source share
4 answers

It's called an icon, and all you have to do is:

  • If there is an icon in /favicon.ico, use it.
  • <link rel="shortcut icon" href="URL goes here" />. HTML <link> rel icon, shortcut icon.
+10

:

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

- json , URL- . www.stackoverflow.com .

gui - , :

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

, -:

{
   "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"
      }
   ]
}
+11

:

imageview1.setImageBitmap(webview1.getFavicon());
+1

Favicon Icon

 private Bitmap fetchFavicon(Uri uri) {
        final Uri iconUri = uri.buildUpon().path("favicon.ico").build();
        Log.i(TAG, "Fetching favicon from: " + iconUri);

        InputStream is = null;
        BufferedInputStream bis = null;
        try
        {
            URLConnection conn = new URL(iconUri.toString()).openConnection();
            conn.connect();
            is = conn.getInputStream();
            bis = new BufferedInputStream(is, 8192);
            return BitmapFactory.decodeStream(bis);
        } catch (IOException e) {
            Log.w(TAG, "Failed to fetch favicon from " + iconUri, e);
            return null;
        }
    }
0

All Articles