nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: hhursev/recipe-scrapers
Pull request #304 (2021-01-25 04:41:00)

make budgebytes use schema


Patch:
diff --git a/recipe_scrapers/budgetbytes.py b/recipe_scrapers/budgetbytes.py
index be0fdae1..965359df 100644
--- a/recipe_scrapers/budgetbytes.py
+++ b/recipe_scrapers/budgetbytes.py
@@ -1,5 +1,4 @@
 from ._abstract import AbstractScraper
-from ._utils import get_minutes, normalize_string, get_yields
 
 
 class BudgetBytes(AbstractScraper):
@@ -8,38 +7,19 @@ class BudgetBytes(AbstractScraper):
         return "budgetbytes.com"
 
     def title(self):
-        return self.soup.find("h2", {"class": "wprm-recipe-name"}).get_text()
+        return self.schema.title()
 
     def total_time(self):
-        return get_minutes(
-            self.soup.find("span", {"class": "wprm-recipe-total_time"}).parent
-        )
+        return self.schema.total_time()
 
     def yields(self):
-        yields = self.soup.find("span", {"class": "wprm-recipe-servings"}).get_text()
-
-        return get_yields("{} servings".format(yields))
+        return self.schema.yields()
 
     def ingredients(self):
-        ingredients = self.soup.findAll("li", {"class": "wprm-recipe-ingredient"})
-
-        return [normalize_string(ingredient.get_text()) for ingredient in ingredients]
+        return self.schema.ingredients()
 
     def instructions(self):
-        instructions = self.soup.findAll(
-            "div", {"class": "wprm-recipe-instruction-text"}
-        )
-
-        return "\n".join(
-            [normalize_string(instruction.get_text()) for instruction in instructions]
-        )
+        return self.schema.instructions()
 
     def ratings(self):
-        return round(
-            float(
-                self.soup.find(
-                    "span", {"class": "wprm-recipe-rating-average"}
-                ).get_text()
-            ),
-            2,
-        )
+        return self.schema.ratings()


Test patch:
diff --git a/tests/test_budgetbytes.py b/tests/test_budgetbytes.py
index a72859c5..94405693 100644
--- a/tests/test_budgetbytes.py
+++ b/tests/test_budgetbytes.py
@@ -25,7 +25,9 @@ class TestBudgetBytesScraper(ScraperTest):
         self.assertEqual(45, self.harvester_class.total_time())
 
     def test_yields(self):
-        self.assertEqual("4 serving(s)", self.harvester_class.yields())
+        self.assertEqual(
+            "4 1.25 cups curry lentils + 1 cup rice", self.harvester_class.yields()
+        )
 
     def test_ingredients(self):
         self.assertCountEqual(