Scraping API Prices
MenuClose

Search the site

82 providers, their alternatives and head-to-heads, targets, guides and answers

Home / Cost tools / cURL converter / Elixir

cURL to Elixir converter

Paste a cURL command and get the same request in Elixir, using HTTPoison. It converts in your browser; nothing you paste is sent anywhere.

Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.

Elixir, with HTTPoison
# mix.exs: {:httpoison, "~> 2.2"}
url = "https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us"
headers = [
  {"Authorization", "Bearer YOUR_API_KEY"}
]
body = ""

case HTTPoison.request(:get, url, body, headers) do
  {:ok, %HTTPoison.Response{status_code: status, body: body}} ->
    IO.puts(status)
    IO.puts(body)
  {:error, %HTTPoison.Error{reason: reason}} ->
    IO.inspect(reason)
end

Running the code

Add HTTPoison to the deps in mix.exs, run mix deps.get, then run the code in iex -S mix. Headers are a list of tuples and the body a string.

Where HTTPoison differs from curl

HTTPoison returns {:ok, response} for any HTTP status, so a 403 is a successful call carrying status_code 403; {:error, reason} means the connection itself failed.

What calls like this one cost

The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $19.00 on BrowserCloud, the cheapest complete bills across 27 web scraping APIs this site prices from their own pages. What rendering adds on each API

The same command in another language