Repository: hhursev/recipe-scrapers

Issue:
Real Simple Ingredients
**Pre-filing checks**

- [x] I have searched for open issues that report the same problem
- [x] I have checked that the bug affects the latest version of the library

**The URL of the recipe(s) that are not being scraped correctly**

- [https://www.realsimple.com/crispy-peanut-tofu-with-sugar-snap-peas-and-peppers-recipe-7229744]

...

**The results you expect to see**
Expect an ingredient list.
...

**The results (including any Python error messages) that you are seeing**
recipe.ingredients()
['1 cup long-grain white rice']
...

Script is only pulling the first ingredient in the recipe. Having a harder time figuring out the fix on this one

Discussion:

Patch:
diff --git a/recipe_scrapers/realsimple.py b/recipe_scrapers/realsimple.py
index 29ef67ff..cfed0b8a 100644
--- a/recipe_scrapers/realsimple.py
+++ b/recipe_scrapers/realsimple.py
@@ -20,12 +20,26 @@ class RealSimple(AbstractScraper):
         return self.schema.total_time()
 
     def yields(self):
-        return get_yields(
-            self.soup.find("div", string=re.compile(r"Yield:")).parent.get_text()
-        )
+        yield_container = self.soup.find("div", string=re.compile(r"Yield:"))
+        if yield_container and yield_container.parent:
+            return get_yields(yield_container.parent.get_text())
+
+        return self.schema.yields()
 
     def ingredients(self):
-        return self.schema.ingredients()
+        ingredient_elements = self.soup.findAll(
+            "li", {"class": "mntl-structured-ingredients__list-item"}
+        )
+        extracted_ingredients = [
+            element.get_text(strip=True, separator=" ")
+            for element in ingredient_elements
+            if element.get_text()
+        ]
+
+        if extracted_ingredients:
+            return extracted_ingredients
+        else:
+            return self.schema.ingredients()
 
     def instructions(self):
         return self.schema.instructions()


Test patch:
diff --git a/tests/test_realsimple.py b/tests/test_realsimple.py
index d41ff6c2..b75b1a6a 100644
--- a/tests/test_realsimple.py
+++ b/tests/test_realsimple.py
@@ -34,26 +34,24 @@ class TestRealSimpleScraper(ScraperTest):
         self.assertEqual("10 servings", self.harvester_class.yields())
 
     def test_ingredients(self):
-        self.assertEqual(
-            [
-                "Cake:",
-                "18 graham crackers (2 sleeves)",
-                "0.5 cup (1 stick) unsalted butter, melted",
-                "0.25 teaspoon kosher salt",
-                "1 cup plus 4 tablespoons sugar",
-                "3 8-ounce packages cream cheese, at room temperature",
-                "2 cups sour cream, at room temperature",
-                "1.5 teaspoons pure vanilla extract",
-                "3 large eggs, at room temperature",
-                "Cherry sauce:",
-                "1 10-ounce bag frozen cherries",
-                "0.5 cup sugar",
-                "0.25 teaspoon kosher salt",
-                "1 tablespoons cornstarch",
-                "2 tablespoons fresh lemon juice",
-            ],
-            self.harvester_class.ingredients(),
-        )
+        expected_ingredients = [
+            "Cake:",
+            "18 graham crackers (2 sleeves)",
+            "½ cup (1 stick) unsalted butter, melted",
+            "¼ teaspoon kosher salt",
+            "1 cup plus 4 tablespoons sugar",
+            "3 8-ounce packages cream cheese, at room temperature",
+            "2 cups sour cream, at room temperature",
+            "1 ½ teaspoons pure vanilla extract",
+            "3 large eggs, at room temperature",
+            "Cherry sauce:",
+            "1 10-ounce bag frozen cherries",
+            "½ cup sugar",
+            "¼ teaspoon kosher salt",
+            "1 tablespoons cornstarch",
+            "2 tablespoons fresh lemon juice",
+        ]
+        self.assertEqual(expected_ingredients, self.harvester_class.ingredients())
 
     def test_instructions(self):
         self.assertEqual(