Skip to content

Instantly share code, notes, and snippets.

@m040601
Created October 29, 2010 14:59
Show Gist options
  • Save m040601/653699 to your computer and use it in GitHub Desktop.
Save m040601/653699 to your computer and use it in GitHub Desktop.
fetch delicious data with Hpricot and OpenURI
class Delicious
class << self
def tag(username, name, count = 15)
links = []
url = "http://feeds.delicious.com/v2/rss/#{username}/#{name}?count=#{count}"
feed = Hpricot(open(url))
feed.search("item").each do |i|
item = OpenStruct.new
item.link = i.at('link').next.to_s
item.title = i.at('title').innerHTML
item.description = i.at('description').innerHTML rescue nil
links << item
end
links
end
end
end
# Return last 15 items tagged with business and news from jebus's account:
Delicious.tag 'jebus', 'business+news', 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment