From 9c61d1e07d17a3bb7739eff84a1d1bdcda46729a Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari Date: Mon, 24 May 2021 01:03:15 +0530 Subject: [PATCH] this closes issue #383 --- recipe_scrapers/thespruceeats.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/recipe_scrapers/thespruceeats.py b/recipe_scrapers/thespruceeats.py index 11ae3cf7c..7ccb44c52 100644 --- a/recipe_scrapers/thespruceeats.py +++ b/recipe_scrapers/thespruceeats.py @@ -29,11 +29,17 @@ def image(self): return image["src"] if image else None def ingredients(self): - # ingredients = self.soup.findAll("li", {"class": "ingredient"}) + """ + It uses two class to get the ingredient list items since sometimes 'ingredient' class is + present for simple recipes but if the recipe contains 2 or more sub-recipe / nested recipe + than 'structured-ingredients__list-item' class is present. + In any case only one class is present. + """ ingredients = self.soup.find( "section", - {"class": "comp section--fixed-width section--ingredients section"}, - ).find_all("li", {"class": "structured-ingredients__list-item"}) + {"class": "section--ingredients"}, + ).find_all("li", {"class": ["structured-ingredients__list-item", "ingredient"]}) + return [normalize_string(ingredient.get_text()) for ingredient in ingredients] def instructions(self):