Skip to content

Commit

Permalink
removed unused imports in food.com scraper (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya2704 committed Aug 19, 2022
1 parent 998a3ad commit a97807b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
20 changes: 8 additions & 12 deletions recipe_scrapers/food.py
@@ -1,5 +1,4 @@
from ._abstract import AbstractScraper
from ._utils import get_minutes, get_yields, normalize_string


class Food(AbstractScraper):
Expand All @@ -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()
10 changes: 5 additions & 5 deletions tests/test_food.py
Expand Up @@ -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 12 teaspoons salt",
"14 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)",
"14 cup chopped fresh dill",
"14 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(),
)

Expand Down

0 comments on commit a97807b

Please sign in to comment.