Class: Firecrawl::Models::ScrapeOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/firecrawl/models/scrape_options.rb

Overview

Options for scraping a single URL.

Constant Summary collapse

FIELDS =
%i[
  formats headers include_tags exclude_tags only_main_content
  timeout wait_for mobile parsers actions location
  skip_tls_verification remove_base64_images block_ads proxy
  max_age store_in_cache integration
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ ScrapeOptions

Returns a new instance of ScrapeOptions.



16
17
18
19
# File 'lib/firecrawl/models/scrape_options.rb', line 16

def initialize(**kwargs)
  FIELDS.each { |f| instance_variable_set(:"@#{f}", kwargs[f]) }
  @skip_tls_verification = true if @skip_tls_verification.nil?
end

Instance Method Details

#to_hObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/firecrawl/models/scrape_options.rb', line 21

def to_h
  {
    "formats" => formats,
    "headers" => headers,
    "includeTags" => include_tags,
    "excludeTags" => exclude_tags,
    "onlyMainContent" => only_main_content,
    "timeout" => timeout,
    "waitFor" => wait_for,
    "mobile" => mobile,
    "parsers" => parsers,
    "actions" => actions,
    "location" => location.is_a?(Hash) ? location : location&.to_h,
    "skipTlsVerification" => skip_tls_verification,
    "removeBase64Images" => remove_base64_images,
    "blockAds" => block_ads,
    "proxy" => proxy,
    "maxAge" => max_age,
    "storeInCache" => store_in_cache,
    "integration" => integration,
  }.compact
end