I think a small update on what techniques to get Favicons are still working is interesting here.
As far as I know, the Google and Duckduckgo solutions are still working.
The accepted solution using YQL is not working in all cases. It is looking for a <link>
tag but favicons are way more complex than that. For instance you can have default /favicon.ico
without any reference into the code. Other example, the <base>
HTML define a default base URL to all relative links in the page including favicons, and so on. You can find more on the different techniques to define a favicon here.
I would recommend using an existing library but usually they are not exhaustive. Here is a project in Javascript: favicongrabber.com. But In my experience libraries in other languages are more exhaustive: