diff --git a/recipe_scrapers/food.py b/recipe_scrapers/food.py index 3950ad29a..0b3b37ca6 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 @@ def host(cls): 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() diff --git a/tests/test_food.py b/tests/test_food.py index 4f0ac308d..b4c75e215 100644 --- a/tests/test_food.py +++ b/tests/test_food.py @@ -34,19 +34,19 @@ def test_ingredients(self): "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(), )