Class: Scruber::Core::Extensions::ParserAliases

Inherits:
Base
  • Object
show all
Defined in:
lib/scruber/core/extensions/parser_aliases.rb

Overview

DSL for registering parsers.

Examples:

Sample of DSL

Scruber.run :sample do
  get 'https://example.com'
  get_product 'https://example.com/product1.html'

  # Parsing https://example.com
  parse :html do |page,doc|
    log doc.at('title').text
  end

  # Parsing https://example.com/product1.html
  parse_product :html do |page,doc|
    log doc.at('title').text
  end
  # Alias to
  # parser :product, format: :html do |page,doc|
  #   log doc.at('title').text
  # end
end

Author:

  • Ivan Gocharov

Defined Under Namespace

Modules: CoreMethods

Method Summary

Methods inherited from Base

descendants, inherited, register