/ruby-firecrawl

Primary LanguageRubyMIT LicenseMIT

Ruby Firecrawl

This is a library written in Ruby to communicate with Firecrawl. Many functions are not implemented.

Installation

gem 'ruby-firecrawl', github: "nc163/ruby-firecrawl"

Usage

simple

require 'firecrawl'

firecrawl = Firecrawl::API::V1::Client.new(url: 'http://127.0.0.1:3002')
result = firecrawl.scrape('https://www.firecrawl.dev')

or if rails, create a file in config/initializers/firecrawl.rb and add the following code:

require 'firecrawl'

#= initialize
Firecrawl::configure do |config|
  # config.api_key = 'xxxx'
  config.url = 'http://127.0.0.1:3002'
end

scrape

firecrawl = Firecrawl::API::V1::Client.new
result = firecrawl.scrape('https://www.firecrawl.dev')
puts result

scrape + extract

firecrawl = Firecrawl::API::V1::Client.new

extract = { 
  schema: 
  {
    'type': 'object',
    'required': ['twitterAccountUrl', 'githubRepositoryUrl'],
    'properties': {
      'twitterAccountUrl': { "type": "string" },
      'githubRepositoryUrl': { "type": "string" }
    }
  }
}
result = client.scrape('https://www.firecrawl.dev', formats: ['extract'], timeout: 12000, extract: extract)
puts result

crawl

firecrawl = Firecrawl::API::V1::Client.new
result = firecrawl.crawl('https://www.firecrawl.dev')
puts result