Skip to content

Instantly share code, notes, and snippets.

@hungryblank
Created July 9, 2009 19:44
Show Gist options
  • Save hungryblank/143946 to your computer and use it in GitHub Desktop.
Save hungryblank/143946 to your computer and use it in GitHub Desktop.
require 'nokogiri'
class Page
attr_accessor :html
include EM::Deferrable
def initialize(url_as_a_hash)
client = EM::Protocols::HttpClient.request(url_as_a_hash)
@html = nil
client.callback do |response|
self.html = response[:content]
self.succeed
end
client.errback { self.fail }
end
def links
Nokogiri::HTML(html) / 'a'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment