Sameer Borate has a a new tutorial posted to his blog about grabbing favicons with curl and the help of the Google Shared Stuff API.
Google Shared Stuff allows one to easily get the Favicon of any website with a single line. [...] This [curl request] will display the Favicon in the browser. An even more interesting thing we can do is to save the same to a PNG file.
He includes the code to make the curl request to the Google service and save it as the local PNG file. Built on top of this is another script that handles multiple sites (his example uses six different sites), pulls down each of the images and pushes them all together into one. You can see an example here.