Class: Firecrawl::ScrapeOptions

Inherits:
Object
  • Object
show all
Includes:
DynamicSchema::Definable, Helpers
Defined in:
lib/firecrawl/scrape_options.rb

Constant Summary collapse

FORMATS =
[ :summary, :markdown, :html, :raw_html, :links, :screenshot ]
ACTIONS =
[ :wait, :click, :write, :press, :screenshot, :scrape ]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#string_camelize

Constructor Details

#initialize(options = {}, api_options: nil) ⇒ ScrapeOptions

Returns a new instance of ScrapeOptions.



78
79
80
81
# File 'lib/firecrawl/scrape_options.rb', line 78

def initialize( options = {}, api_options: nil )
  @options = self.class.builder.build( options || {} )
  @options = api_options.merge( @options ) if api_options 
end

Class Method Details

.build(options = nil, &block) ⇒ Object



58
59
60
# File 'lib/firecrawl/scrape_options.rb', line 58

def self.build( options = nil, &block )
  new( api_options: builder.build( options, &block ) )
end

.build!(options = nil, &block) ⇒ Object



62
63
64
# File 'lib/firecrawl/scrape_options.rb', line 62

def self.build!( options = nil, &block )
  new( api_options: builder.build!( options, &block ) )
end

.normalize_options(options) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/firecrawl/scrape_options.rb', line 66

def self.normalize_options( options )
  options = options&.dup || {}
  screenshot = options.delete( :screenshot )
  if screenshot
    formats = options[ :formats ] || []
    formats.delete( :screenshot )
    formats << screenshot 
    options[ :formats ] = formats
  end
  options 
end

Instance Method Details

#to_hObject



83
84
85
# File 'lib/firecrawl/scrape_options.rb', line 83

def to_h
  @options.to_h 
end