Skip to content

Commit

Permalink
Groupings and Improved Ingredient Parsing for JamieOliver (#1434)
Browse files Browse the repository at this point in the history
  • Loading branch information
jknndy authored Dec 14, 2024
1 parent 3d5f6e4 commit 5fc6ded
Show file tree
Hide file tree
Showing 6 changed files with 501 additions and 1,257 deletions.
15 changes: 15 additions & 0 deletions recipe_scrapers/jamieoliver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ._abstract import AbstractScraper
from ._grouping_utils import group_ingredients
from ._utils import normalize_string


Expand All @@ -12,3 +13,17 @@ def instructions(self):
instructions_list = method_heading.find_next("ol")
instructions = instructions_list.find_all("li")
return "\n".join([normalize_string(inst.get_text()) for inst in instructions])

def ingredients(self):
ingredients_list = self.soup.select(".ingredients-rich-text p.type-body")
return [
normalize_string(ingredient.get_text()) for ingredient in ingredients_list
]

def ingredient_groups(self):
return group_ingredients(
self.ingredients(),
self.soup,
".ingredients-rich-text p.type-h5",
".ingredients-rich-text p.type-body",
)
1,223 changes: 0 additions & 1,223 deletions tests/test_data/jamieoliver.com/jamieoliver.testhtml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"author": "Jamie Oliver",
"canonical_url": "https://www.jamieoliver.com/recipes/chocolate-recipes/bloomin-brilliant-brownies/",
"canonical_url": "https://www.jamieoliver.com/recipes/chocolate/bloomin-brilliant-brownies/",
"site_name": "Jamie Oliver",
"host": "jamieoliver.com",
"language": "en",
"language": "en-GB",
"title": "Bloomin' brilliant brownies",
"ingredients": [
"200 g quality dark chocolate (70%)",
"250 g unsalted butter",
"75 g dried sour cherries optional",
"50 g chopped nuts optional",
"80 g quality cocoa powder",
"65 g plain flour",
"200g quality dark chocolate (70%)",
"250g unsalted butter",
"optional: 75g dried sour cherries",
"optional: 50g chopped nuts",
"80g quality cocoa powder",
"65g plain flour",
"1 teaspoon baking powder",
"360 g caster sugar",
"360g caster sugar",
"4 large free-range eggs"
],
"instructions_list": [
Expand All @@ -24,36 +24,26 @@
"Pour the brownie mix into the baking tin, and place in the oven for around 25 minutes. You don’t want to overcook them so, unlike cakes, you don’t want a skewer to come out clean – the brownies should be slightly springy on the outside but still gooey in the middle.",
"Allow to cool in the tray, then carefully transfer to a large chopping board and cut into chunky squares. Delicious served with a dollop of crème fraîche or yoghurt mixed with some orange zest."
],
"category": "Desserts",
"category": "Baking",
"yields": "20 servings",
"description": "This is a great little recipe for easy, fail-safe, gloriously gooey chocolate brownies",
"description": "This easy brownie recipe from Jamie Oliver never disappoints. It's totally foolproof, and packed with dark chocolate, chopped nuts, cocoa powder and sour cherries. Perfect for weekend baking.",
"total_time": 40,
"cuisine": "https://schema.org/VegetarianDiet",
"cook_time": 40,
"nutrients": {
"calories": "291 calories",
"fatContent": "18.4 g fat",
"saturatedFatContent": "10.1 g saturated fat",
"carbohydrateContent": "28.3 g carbohydrate",
"sugarContent": "24.6 g sugar",
"proteinContent": "3.9 g protein",
"sodiumContent": "0.2 g salt",
"fiberContent": "1.6 g fibre"
"fat": "18.4 g",
"portionWeight": "45.9 g",
"protein": "3.9 g",
"salt": "0.2 g",
"saturatedFat": "10.1 g",
"carbs": "28.3 g",
"classification": "140",
"fibre": "1.6 g",
"sugars": "24.6 g"
},
"image": "https://img.jamieoliver.com/jamieoliver/recipe-database/oldImages/large/88_1_1441269331.jpg?tr=w-800,h-800",
"image": "https://asset.jamieoliver.com/images/cq7w2e71/production/f1e42faa99fb1756e2e1463a8b6af3429a4c323a-1447x2171.jpg/brillbrownies.jpg?rect=0,432,1447,1447&w=600&h=600&fm=webp&q=75&fit=crop&auto=format",
"keywords": [
"chocolate",
"brownies",
"brownie",
"vegetarian",
"sweets and desserts",
"baking",
"cooking",
"chocolate brownies",
"party food",
"baking and desserts",
"Christmas",
"Dinner Party",
"non-promotable",
"Popular"
"Party Food",
"Chocolate Main Ingredient"
]
}
Loading

0 comments on commit 5fc6ded

Please sign in to comment.