Skip to content

Commit

Permalink
this closes issue hhursev#383
Browse files Browse the repository at this point in the history
  • Loading branch information
khushhalm committed May 23, 2021
1 parent 014410f commit 9c61d1e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions recipe_scrapers/thespruceeats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9c61d1e

Please sign in to comment.