Created
October 29, 2010 14:59
-
-
Save m040601/653699 to your computer and use it in GitHub Desktop.
fetch delicious data with Hpricot and OpenURI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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