lib/randomizer/all_avatars_site.rb in randomizer-0.0.2 vs lib/randomizer/all_avatars_site.rb in randomizer-0.0.3

- old
+ new

@@ -1,8 +1,7 @@ require 'net/http' -require 'rubygems' -require 'hpricot' +require 'nokogiri' class AllAvatarsSite def self.instance @@instance ||= AllAvatarsSite.new @@ -15,12 +14,12 @@ def load_urls while @unused_avatar_urls.empty? path = "/avatars/showgallery.php?si=&perpage=18&sort=6&cat=all&ppuser=" response = Net::HTTP.get_response("www.allavatars.com", path).body - doc = Hpricot(response) - doc.search("img") do |img| - source = img.attributes['src'] + doc = Nokogiri::HTML(response) + (doc/'img').each do |img| + source = img['src'] if source =~ %r{http://www.allavatars.com/avatars/data/.*} && !@used_avatar_urls.member?(source) @unused_avatar_urls << source end end end \ No newline at end of file