Skip to content

Commit

Permalink
Fix ingredients for simplyrecipes.com scraper
Browse files Browse the repository at this point in the history
Update the CSS class for ingredients. While here, also update the
formatting of instructions such that colon isn't repeated twice.
Refetch the test HTML file for verification.

Test: python -m coverage run -m unittest tests.test_simplyrecipes
  • Loading branch information
puradox committed Oct 9, 2022
1 parent 516da03 commit 1211a4d
Show file tree
Hide file tree
Showing 3 changed files with 1,826 additions and 1,480 deletions.
6 changes: 4 additions & 2 deletions recipe_scrapers/simplyrecipes.py
Expand Up @@ -28,7 +28,9 @@ def yields(self):
)

def ingredients(self):
ingredients = self.soup.find("ul", {"class": "ingredient-list"}).findAll("li")
ingredients = self.soup.find(
"ul", {"class": "structured-ingredients__list"}
).findAll("li")

return [normalize_string(ingredient.get_text()) for ingredient in ingredients]

Expand All @@ -40,7 +42,7 @@ def instructions(self):
return "\n".join(
[
normalize_string(
step.div.text + ": " + "".join([p.text for p in step.findAll("p")])
step.div.text + "".join([p.text for p in step.findAll("p")])
)
for step in steps
]
Expand Down

0 comments on commit 1211a4d

Please sign in to comment.