Repository: hhursev/recipe-scrapers

Issue:
Broken Scraper for food.com
Thanks for filing a bug report with us!

If your request is about a website that is not supported, please open a 'new scraper' issue request instead.

To help get the issue fixed, please fill in the information below.

**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.food.com/recipe/chicken-noodle-soup-with-carrots-parsnips-and-dill-454415

**The version of Python you're using**

3.8.9

**The operating system of your environment**

MacOS

**The results you expect to see**

Ingredients and instructions to be extracted

**The results (including any Python error messages) that you are seeing**

Instructions and ingredients are coming as empty. I noticed the issue is with the scraper for food.com. The html class names have been changed, that's why the scraper appears to be broken. The site supports schema method so it can be fixed with that approach.

Can you write Python and would you like to help fix the scraper yourself?  We'd be glad for your assistance!  We can provide you with guidance and code review in return.  If so, tick any of the relevant boxes below:

- [x] I'd like to try fixing this scraper myself
- [ ] I'd like guidance to help me develop a fix
- [ ] I'd prefer if the `recipe-scrapers` team try to fix this


Discussion:
hhursev: Thanks! Merging and will bump version shortly

Patch:
diff --git a/recipe_scrapers/food.py b/recipe_scrapers/food.py
index 3950ad29..0b3b37ca 100644
--- a/recipe_scrapers/food.py
+++ b/recipe_scrapers/food.py
@@ -1,5 +1,4 @@
 from ._abstract import AbstractScraper
-from ._utils import get_minutes, get_yields, normalize_string
 
 
 class Food(AbstractScraper):
@@ -8,22 +7,19 @@ class Food(AbstractScraper):
         return "food.com"
 
     def title(self):
-        return self.soup.find("h1").get_text()
+        return self.schema.title()
 
     def total_time(self):
-        return get_minutes(self.soup.find("div", {"class": "recipe-facts__time"}))
+        return self.schema.total_time()
 
     def yields(self):
-        return get_yields(
-            self.soup.find("div", {"class": "recipe-facts__servings"}).get_text()
-        )
+        return self.schema.yields()
 
-    def ingredients(self):
-        ingredients = self.soup.findAll("li", {"class": "recipe-ingredients__item"})
+    def image(self):
+        return self.schema.image()
 
-        return [normalize_string(ingredient.get_text()) for ingredient in ingredients]
+    def ingredients(self):
+        return self.schema.ingredients()
 
     def instructions(self):
-        instructions = self.soup.findAll("li", {"class": "recipe-directions__step"})
-
-        return "\n".join([instruction.get_text() for instruction in instructions])
+        return self.schema.instructions()


Test patch:
diff --git a/tests/test_food.py b/tests/test_food.py
index 4f0ac308..b4c75e21 100644
--- a/tests/test_food.py
+++ b/tests/test_food.py
@@ -34,19 +34,19 @@ class TestFoodScraper(ScraperTest):
                 "1 onion, chopped",
                 "4 carrots, halved lengthwise and cut crosswise into 1-inch pieces",
                 "4 parsnips, halved lengthwise and cut crosswise into 1-inch pieces",
-                "1 1⁄2 teaspoons salt",
-                "1⁄4 teaspoon fresh ground black pepper",
+                "1 1/2 teaspoons salt",
+                "1/4 teaspoon fresh ground black pepper",
                 "1 split chicken breast",
                 "1 cup noodles (about 2 ounces)",
-                "1⁄4 cup chopped fresh dill",
-                "1⁄4 cup chopped fresh parsley",
+                "1/4 cup chopped fresh dill",
+                "1/4 cup chopped fresh parsley",
             ],
             self.harvester_class.ingredients(),
         )
 
     def test_instructions(self):
         return self.assertEqual(
-            "In a large pot, combine the broth, onion, carrots, parsnips, salt, and pepper and bring to a simmer. Add the chicken breasts to the pot and simmer until jfor about 20 minutes, until cooked. Remove the chicken and let rest.  When cool enough to handle, remove skin and bones and chop or shred intobite-size pieces.\nWhile chicken is cooling, bring the soup back to a simmer and stir the noodles into the soup. Simmer until the vegetables are tender and the noodles are done, about 5 minutes. Return the chicken pieces to the pot and then stir in the dill and the parsley.",
+            "In a large pot, combine the broth, onion, carrots, parsnips, salt, and pepper and bring to a simmer. Add the chicken breasts to the pot and simmer until jfor about 20 minutes, until cooked. Remove the chicken and let rest. When cool enough to handle, remove skin and bones and chop or shred intobite-size pieces.\nWhile chicken is cooling, bring the soup back to a simmer and stir the noodles into the soup. Simmer until the vegetables are tender and the noodles are done, about 5 minutes. Return the chicken pieces to the pot and then stir in the dill and the parsley.",
             self.harvester_class.instructions(),
         )