The project is in a healthy, maintained state
Realistic browser-like HTTP requests using curl-impersonate's impersonation capabilities.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 1.15
 Project Readme

Ethon Impersonate Chrome Edge Safari Firefox Tor

Gem Version Build Status

Ethon Impersonate is a fork of Ethon that wraps libcurl-impersonate.

In Greek mythology, Ethon, the son of Typhoeus and Echidna, is a gigantic eagle. So much for the history.

This allows you to make HTTP requests that appear to come from real browsers, helping to bypass bot detection and fingerprinting.

Installation

With bundler:

gem "ethon-impersonate"

With rubygems:

gem install ethon-impersonate

Dependencies

On MacOS Apple Silicon, you need to install the following dependencies using Homebrew:

brew install libidn2 rtmpdump zstd

Note: Homebrew must be loaded in the same arch than the Ruby interpreter. If you are using arch -x86_64 to run Ruby, you must also run Homebrew with arch -x86_64 brew install ....

Usage

Making the first request is simple:

easy = EthonImpersonate::Easy.new(url: "www.example.com")
easy.perform
#=> :ok

You have access to various options, such as following redirects:

easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
easy.perform
#=> :ok

Once you're done you can inspect the response code and body:

easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
easy.perform
easy.response_code
#=> 200
easy.response_body
#=> "<!doctype html><html ..."

Browser Impersonation

The main feature of this gem is the ability to impersonate real browsers. Use the impersonate method to configure the request to look like it's coming from a specific browser:

easy = EthonImpersonate::Easy.new(url: "www.example.com")
easy.impersonate("chrome136")  # Impersonate Chrome 136
easy.perform
easy.response_code
#=> 200

Available Browser Targets

The gem supports all browser targets available in curl-impersonate. Some popular targets include:

  • Chrome: chrome136, chrome131_android
  • Firefox: firefox135
  • Safari: safari184, safari184_ios
  • Edge: edge101
  • Tor: tor145

For a complete list of available targets, see the curl-impersonate bin directory.

Example with Browser Impersonation

# Impersonate Chrome 136
easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
easy.impersonate("chrome136")
easy.perform
#=> :ok

# Impersonate Firefox 135
easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
easy.impersonate("firefox135")
easy.perform
#=> :ok

# Impersonate Safari 184
easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
easy.impersonate("safari184")
easy.perform
#=> :ok

Http

In order to make life easier, there are some helpers for making HTTP requests:

easy = EthonImpersonate::Easy.new
easy.http_request("www.example.com", :get, { params: {a: 1} })
easy.perform
#=> :ok
easy = EthonImpersonate::Easy.new
easy.http_request("www.example.com", :post, { params: { a: 1 }, body: { b: 2 } })
easy.perform
#=> :ok

This is really handy when making requests since you don't have to care about setting everything up correctly.

Http2

Standard http2 servers require the client to connect once and create a session (multi) and then add simple requests to the multi handler. The perform method then takes all the requests in the multi handler and sends them to the server.

See the following example

multi = EthonImpersonate::Multi.new
easy = EthonImpersonate::Easy.new

easy.http_request("www.example.com/get", :get, { http_version: :httpv2_0 })

# Sending a request with http version 2 will send an Upgrade header to the server, which many older servers will not support
# See below for more info: https://everything.curl.dev/http/http2
# If this is a problem, send the below:
easy.http_request("www.example.com/get", :get, { http_version: :httpv2_prior_knowledge })

# To set the server to use http2 with https and http1 with http, send the following:
easy.http_request("www.example.com/get", :get, { http_version: :httpv2_tls })

multi.add(easy)
multi.perform

Sponsors

Ethon Impersonate is maintained by SerpApi.

Thanks to all contributors of this project past and present.


SerpAPI

Scrape Google and other search engines from SerpApi's fast, easy, and complete API. 0.66s average response time (≤ 0.5s for Ludicrous Speed Max accounts), 99.95% SLAs, pay for successful responses only.