0.0
The project is in a healthy, maintained state
Reads the title, ingredients, steps, times, yields and nutrition of a recipe from its page. Uses the schema.org JSON-LD or microdata the site publishes, falls back to OpenGraph, and takes a short per-site declaration where a site publishes no structured data. Fetches through a Faraday connection guarded against SSRF, or parses HTML you already have.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.9.0, < 3
>= 3.1.0, < 4
>= 2.2.0, < 3
>= 1.15.0, < 2
 Project Readme

recipe_scrapers

GitHub Gem Version Ruby Version CI License

A Ruby gem that reads recipes from cooking websites: the title, ingredients, instructions, times, yields and nutrition. It uses the schema.org markup most recipe sites publish, falls back to OpenGraph, and reads the HTML directly for sites that publish neither. It does not get around bot protection.

Installation

Add it to your Gemfile:

gem "recipe_scrapers", "~> 0.2.0"

Or install it manually:

gem install recipe_scrapers --version "~> 0.2.0"

The gem follows Semantic Versioning. Until 1.0, a minor release can change the public API, so the constraint above takes only patch releases. GitHub releases list the changes of each version. The gem runs on every Ruby version that has not reached its end of life.

Usage

require "recipe_scrapers"

recipe = RecipeScrapers.scrape("https://www.recipetineats.com/crispy-potato-straws-pommes-paille/")
recipe.title                       # => "Crispy potato straws (Pommes Paille)"
recipe.ingredients[1]              # => "1 1/2 - 2 cups vegetable oil (canola, sunflower or peanut oil)"
recipe.parsed_ingredients[1].to_h  # => { amount: 1.5, unit: "cups", name: "vegetable oil" }
recipe.cook_time                   # => 10
recipe.to_h                        # every field as plain data, ready for JSON

To read HTML you already have, without a request:

recipe = RecipeScrapers.parse(html, url: url)

Documentation

Contributing

A site stopped working, or you need a new one? Open an issue with the URL of a recipe page. To add it yourself, see CONTRIBUTING. Report a security problem privately, see SECURITY.

License

MIT, see LICENSE. The pages recorded for the tests are not covered by it, see License.