How can I get a web site's favicon?

前端 未结 14 2143
旧巷少年郎
旧巷少年郎 2020-12-22 15:28

Simple enough question: I\'ve created a small app that is basically just a favourites that sits in my system tray so that I can open often-used sites/folders/files from the

14条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 15:57

    You can do it without programming. Just open the web site, right-click and select "view source" to open the HTML code of that site. Then in the text editor search for "favicon" - it will direct you to something looking like

    
    

    take the string in href and append it to the web site's base URL (let's assume it is "http://WEBSITE/"), so it looks like

    http://WEBSITE/SOMERELATIVEPATH/favicon.ico

    which is the absolute path to the favicon. If you didn't find it this way, it can be as well in the root in which case the URL is http://WEBSITE/favicon.ico.

    Take the URL you determined and insert it into the following code:

    
      
       Capture Favicon   
      
      
        Favicon 
      
    
    

    Save this HTML code locally (e.g. on your desktop) as GetFavicon.html and then double-click on it to open it. It will display only a link named Favicon. Right-click on this link and select "Save target as..." to save the Favicon on your local PC - and you're done!

提交回复
热议问题