0.0
No release in over 3 years
Low commit activity in last 3 years
download a webpage's favicon
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

faviconduit¶ ↑

Attempts to download a URL’s favicon.

Synopsis¶ ↑

raise "url missing" unless uri = ARGV[0]

begin

  fav = Faviconduit.get(uri)

  puts "found favicon at #{fav.url}"

  File.open('favicon.ico', 'w') do |file|
    file.write(fav.data)
  end

rescue Faviconduit::MissingFavicon

  puts "favicon missing"

rescue Faviconduit::InvalidFavicon

  puts "favicon invalid"

end

Methods¶ ↑

Faviconduit.get(uri)

Takes a url and attempts to returns the favicon object. The url can be fairly loosely specified because Addressable::URI.heuristic_parse is used to figure it out.

obj.url

The favicon url it was ultimately found at.

obj.data

The favicon image data.

Exceptions¶ ↑

Faviconduit::MissingFavicon

Raises this if the favicon simply isn’t found.

Faviconduit::InvalidFavicon

Raises this if the favicon is determined to be not a valid favicon. Currently (0.1) determins this if the content-type is not /^image/ or the size is 0 bytes.

Faviconduit::Error

This is the parent of all faviconduit exceptions and can be caught instead of the more specific exceptions.

Copyright © 2010 Kevin Swope. See LICENSE for details.