class Scraprr::Scraper
Attributes
object_scraper[R]
root_path[R]
Public Class Methods
new(root_path = '/')
click to toggle source
# File lib/scraprr/scraper.rb, line 5 def initialize(root_path = '/') @root_path = root_path @object_scraper = ObjectScraper.new end
Public Instance Methods
attribute(name, path = AttributeScraper::DEFAULT_PATH, opts = {})
click to toggle source
# File lib/scraprr/scraper.rb, line 15 def attribute(name, path = AttributeScraper::DEFAULT_PATH, opts = {}) @object_scraper.attribute(name, path, opts) self end
extract(document)
click to toggle source
# File lib/scraprr/scraper.rb, line 20 def extract(document) items = [] document.search(root_path).each do |node| extract_item_into(items, node) end items end
root(path)
click to toggle source
# File lib/scraprr/scraper.rb, line 10 def root(path) @root_path = path self end
Private Instance Methods
extract_item_into(items, node)
click to toggle source
# File lib/scraprr/scraper.rb, line 30 def extract_item_into(items, node) items << @object_scraper.extract(node) rescue MissingAttributeError # skip end