class Grubby::PageScraper
Attributes
page[R]
The Page being scraped.
@return [Mechanize::Page]
Public Class Methods
new(source)
click to toggle source
@param source [Mechanize::Page] @raise [Grubby::Scraper::Error]
if any {Scraper.scrapes} blocks fail
Calls superclass method
Grubby::Scraper::new
# File lib/grubby/page_scraper.rb, line 11 def initialize(source) @page = source.assert!(Mechanize::Page) super end
scrape_file(path, agent = $grubby)
click to toggle source
Scrapes a locally-stored file. This method is intended for use with subclasses of Grubby::PageScraper
.
@example
class MyScraper < Grubby::PageScraper # ... end MyScraper.scrape_file("path/to/local_file.html") # === MyScraper
@param path [String] @param agent [Mechanize] @return [Grubby::PageScraper] @raise [Grubby::Scraper::Error]
if any {Scraper.scrapes} blocks fail
# File lib/grubby/page_scraper.rb, line 31 def self.scrape_file(path, agent = $grubby) self.new(Mechanize::Page.read_local(path).tap{|page| page.mech = agent }) end