You are here: Home » NewsFeeds » Show HN: Recipebook – scrape and parse food recipes on the web

Show HN: Recipebook – scrape and parse food recipes on the web

README.md

This is a simple application for scraping and parsing food recipe data found on the web in hRecipe format, producing results in json.

This project was inspired by this answer to a query for an open database of recipes.

Add your favorite site by implementing a RecipeParser class with appropriate lxml etree definitions of the getIngredients(), getDirections(), getTags(), and getOtherRecipeLinks() methods.

Few sites implement hRecipe exactly, though, so study the site’s html source code to understand its structure. Also see how the current implementations for AllRecipes, Epicurious, FoodNetwork, and Williams Sonoma were written.

Pull requests are welcome!

Individual recipes

Import the class corresponding to the site you want, and use the recipe URL in its constructor.

Here’s an example to fetch and parse the Chocolate, Almond, and Banana Parfaits recipe from Epicurious:

>>> from epicurious import Epicurious
>>> recipe = Epicurious(“http://www.epicurious.com/recipes/food/views/Chocolate-Almond-and-Banana-Parfaits-357369”)

Use the save() method to create a file of the recipe in json object.

The file


 

Original article