Skip to content

Commit

Permalink
fix: update Rewe scraper (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-anders authored Jan 6, 2025
1 parent 5200083 commit f305b88
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 160 deletions.
14 changes: 8 additions & 6 deletions recipe_scrapers/rewe.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def ingredients(self):
ingredients = []

for item in list_items:
text = item.find("div", {"class": "ld-rds flex-[1_0_0%]"})
ingredient_text = (
text.get_text(" ", strip=True).replace("\n", "").replace(" ", " ")
amount = normalize_string(
item.find("div", class_="formattedAmountDiv").get_text()
)
ingredient = item.find(
"span", {"class": "ld-rds break-words leading-6"}
).get_text(" ", strip=True)
ingredients.append(
normalize_string(f"{amount + ' ' if amount != '0' else ''}{ingredient}")
)
ingredient_text = re.sub(r"\s+", " ", ingredient_text)

ingredients.append(ingredient_text)

return ingredients

Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/rewe.de/rewe.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"yields": "4",
"description": "Wir treiben es gerne bunt! Starte auch du mit einer ausgewogenen Familien-Mahlzeit durch. Hol dir das REWE Rezept für Wintergemüse-Gnocchi-Pfanne & Kräuterdip.",
"total_time": 45,
"ratings": 4.63,
"ratings_count": 35,
"ratings": 4.69,
"ratings_count": 42,
"nutrients": {
"servingSize": "4 Portionen",
"calories": "677 kcal"
Expand Down
Loading

0 comments on commit f305b88

Please sign in to comment.