Sha256: baa4f83897103be57c68b1eb69649f9805922bd80771476d305b0ee2ae27746f

Contents?: true

Size: 631 Bytes

Versions: 3

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module Juknife
  # Juknife::Scraper is a scraper to request a web page and to extract data.
  class Scraper
    def initialize
      @scraping = Scraping::Runner.new(&self.class.scraping_block)
      @request = Request::Runner.new(&self.class.request_block)
    end

    def scrape(params = {})
      source = @request.run(params)
      @scraping.run(source, params)
    end

    class << self
      attr_reader :scraping_block, :request_block

      def scraping(&block)
        @scraping_block = block
      end

      def request(&block)
        @request_block = block
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
juknife-0.1.3 lib/juknife/scraper.rb
juknife-0.1.2 lib/juknife/scraper.rb
juknife-0.1.1 lib/juknife/scraper.rb