recipe_scrapers
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 JSONTo read HTML you already have, without a request:
recipe = RecipeScrapers.parse(html, url: url)Documentation
- Supported Sites: every site the gem reads out of the box
- Usage: fetching, other HTTP clients, unsupported sites, errors
- Recipe Fields: every field with its type and an example
- Configuration: timeouts, size limits, your own connection
- Parsers: your own ingredient and nutrient parsers
- API reference
- Changelog
- Copyright and Usage: what you are responsible for
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.