Revisions

gist: 214489 Download_button fork
public
Public Clone URL: git://gist.github.com/214489.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'scrubyt'
 
class RecipeScraper::Base
  def initialize(attributes = {})
    # snip setting instance variables from attributes hash
  end
 
  def data
    raise "Define in subclass"
  end
 
  def scrape_and_save
    xml = data.to_xml
    # snip logic to iterate over the xml and persist
  end
 
end
 
class RecipeScraper::SomeSpecificSite < RecipeScraper::Base
  def data
    @data ||= Scrubyt::Extractor.define :agent => :firefox do
      # snip scrapping logic
      # snip XML generation logic
    end
  end
end