Ruby web scraping libraries

Updated Nov 2026

Ruby web scraping libraries fetch web pages and extract structured data from their HTML. Pages that build their content with JavaScript need a controlled browser to render them before extraction. These libraries let data pipelines and AI agents collect prices, listings, and articles from sites without an API.

Popularity

Nokogiri has the most monthly downloads in this comparison, at 1304424215, a count that covers all its HTML and XML parsing.

LibraryMonthly downloadsStarsLast releaseLicense
Nokogiri
1304424215
6.3KNov 2026MIT
Watir
43086188
1.5KAug 2023MIT
Mechanize
42799551
4.4KOct 2026MIT
Oga
29980372
Not on GitHubJun 2026MPL-2.0
Ferrum
18077697
2.1KNov 2026MIT
playwright-ruby-client
5381415
Not on GitHubNov 2026MIT
Anemone
1358349
Not on GitHubMay 2012MIT
Kimurai
260985
Not on GitHubJan 2026MIT
Downloads: RubyGems, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryURL retrievalJavaScript executionCrawl scheduling
NokogiriUnsupportedUnsupportedUnsupported
WatirBuilt-inBuilt-inUnsupported
MechanizeBuilt-inUnsupportedUnsupported
OgaUnsupportedUnsupportedUnsupported
FerrumBuilt-inBuilt-inUnsupported
playwright-ruby-clientBuilt-inBuilt-inUnsupported
AnemoneBuilt-inUnsupportedBuilt-in
KimuraiBuilt-inBuilt-inBuilt-in
Built-inNot supported

Libraries and code examples

Parses and queries HTML and XML documents from Ruby.

Downloads / mo
1304424215
Stars
6.3K
Last release
1.19.7
License
MIT

Strengths

  • Queries with CSS and XPath. Extract nodes using familiar CSS selectors or XPath paths.
  • Edits parsed document nodes. Change node content, attributes, and positions before serializing the document.

Limitations

  • Encoding guesses can be wrong. Set the encoding explicitly when the source declaration is incorrect.
  • Runtime parsers can behave differently. Check important extraction results when moving between CRuby and JRuby.

Quickstart

From README.md
$ gem install nokogiri -v 1.19.7
require "nokogiri"

puts Nokogiri::HTML("<h1>Hello</h1>").at_css("h1").text

Nokogiri examples

From open-source projects on GitHub

Automates browser clicks, form input, and text checks from Ruby.

Downloads / mo
43086188
Stars
1.5K
Last release
7.3.0
License
MIT

Strengths

  • Waits before acting on elements. Element actions wait for the element to become ready.
  • Offers readable attribute selectors. Find elements by labels, text, and other meaningful attributes.

Limitations

  • CSS selectors must stand alone. Use CSS or XPath without adding other locator keys.
  • Reads need their own waits. Use wait_until before reading content that arrives asynchronously.

Quickstart

From browser.rb
$ gem install watir -v 7.3.0
require "watir"

browser = Watir::Browser.start("https://example.com/")
puts browser.title
browser.close

Watir examples

From open-source projects on GitHub
def element_with_focus
          element = browser.execute_script("return document.activeElement")
          type = element.type.to_sym if element.tag_name.to_sym == :input
          cls = ::PageObject::Elements.element_class_for(element.tag_name, type)
          cls.new(element)
        end

Automates website navigation with cookies, redirects, and form submission.

Downloads / mo
42799551
Stars
4.4K
Last release
2.14.2
License
MIT

Strengths

  • Preserves cookies across navigation. Follow links and redirects while retaining the website session.
  • Fills and submits HTML forms. Populate form fields before submitting through the session.

Limitations

  • JavaScript pages need another tool. Use a browser when required content is generated by JavaScript.

Quickstart

From spider.rb
$ gem install mechanize -v 2.14.2
require "mechanize"

agent = Mechanize.new
puts agent.get("https://example.com/").title

Mechanize examples

From open-source projects on GitHub
def create_page(proxy: nil)
          mechanize = ::Mechanize.new do |m|
            m.user_agent = settings.dig(:headers, "User-Agent")
            m.set_proxy(proxy[:host], proxy[:port], proxy[:user], proxy[:password]) if proxy
          end

          Page.new(mechanize)
        end

Oga is an XML/HTML parser written in Ruby.

Downloads / mo
29980372
Last release
3.5
License
MPL-2.0

Quickstart

From README.md
$ gem install oga -v 3.5
require "oga"

document = Oga.parse_html("<h1>Hello</h1>")
puts document.to_xml

Oga examples

From open-source projects on GitHub

Controls Chrome or Chromium directly through the DevTools Protocol.

Downloads / mo
18077697
Stars
2.1K
Last release
0.20.2
License
MIT

Strengths

  • Controls Chrome without ChromeDriver. Connect directly through CDP, Chrome’s browser-control protocol.
  • Reads JavaScript-rendered page content. Evaluate JavaScript and query elements in a live browser.

Limitations

  • Requires Chrome or Chromium. Use Watir when the workflow needs another browser family.
  • Network-idle waits can fail. Check the boolean result or use wait_for_idle! for an exception.

Quickstart

From README.md
$ gem install ferrum -v 0.20.2
require "ferrum"

browser = Ferrum::Browser.new
browser.go_to("https://example.com/")
puts browser.title
browser.quit

Ferrum examples

From open-source projects on GitHub
def create_page(proxy: nil)
          options = {}
          options.merge!(proxy: proxy) if proxy
          page = browser.create_page(**options)
          Page.new(page, context: browser.contexts[page.context_id])
        end

playwright-ruby-client

Provides the Ruby binding of the Playwright driver.

Downloads / mo
5381415
Last release
1.65.0
License
MIT

Quickstart

From README.md
$ gem install playwright-ruby-client -v 1.65.0
require "playwright"

Playwright.create(playwright_cli_executable_path: "./node_modules/.bin/playwright-core") do |playwright|
  playwright.chromium.launch do |browser|
    page = browser.new_page
    page.goto("https://example.com/")
    puts page.title
  end
end

playwright-ruby-client examples

From open-source projects on GitHub
def playwright_browser
            browser_type = playwright_execution.playwright.send(@browser_type)
            browser_options = @browser_options.value
            browser_type.launch(**browser_options)
          end

Provides a web-spider framework.

Downloads / mo
1358349
Last release
0.7.2
License
MIT

Quickstart

From core.rb
$ gem install anemone -v 0.7.2
require "anemone"

Anemone.crawl("https://example.com/") do |crawler|
  crawler.on_every_page { |page| puts page.url }
end

Anemone examples

From open-source projects on GitHub

Provides a web scraping framework in Ruby based on Capybara and Nokogiri.

Downloads / mo
260985
Last release
2.2.0
License
MIT

Quickstart

From README.md
$ gem install kimurai -v 2.2.0
require "kimurai"

class ExampleSpider < Kimurai::Base
  @engine = :mechanize
  @start_urls = ["https://example.com/"]
  def parse(response, url:, data: {})
    puts url
  end
end

ExampleSpider.crawl!

Kimurai examples

From open-source projects on GitHub
def parse(response, url:, data: {})
    Parallel.each(response.css('a.category-list-item-link')) do |framework|
      request_to :parse_framework, url: URI.join('https://developer.apple.com/', framework[:href]).to_s
    rescue StandardError => e
      puts "There is failed request (#{e.inspect}), skipping it..."
    end
  end

FAQ

Nokogiri suits parsing fetched HTML with CSS selectors or XPath. Mechanize suits sites that need cookies, redirects, and form submission. Ferrum suits pages that JavaScript renders in Chrome.

Nokogiri parses and queries HTML and XML documents from Ruby with CSS selectors or XPath.

Watir automates browser clicks, form input, and text checks from Ruby. Element actions wait for each element to become ready.

Ferrum controls Chrome or Chromium directly through the DevTools Protocol, without ChromeDriver.

No. Content generated by JavaScript needs a browser such as Ferrum or Watir.

For coding agents

Found your web scraping library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official