Skip to content

Commit

Permalink
Adds support for Eatwell101.com (hhursev#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
jknndy authored and strangetom committed Nov 12, 2023
1 parent f45c4a1 commit 88231b8
Show file tree
Hide file tree
Showing 5 changed files with 5,445 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Scrapers available for:
- `https://www.eatingwell.com/ <https://www.eatingwell.com>`_
- `https://eatsmarter.com/ <https://eatsmarter.com/>`_
- `https://eatsmarter.de/ <https://eatsmarter.de/>`_
- `https://www.eatwell101.com <https://www.eatwell101.com>`_
- `https://eatwhattonight.com/ <https://eatwhattonight.com/>`_
- `https://emmikochteinfach.de/ <https://emmikochteinfach.de/>`_
- `https://ethanchlebowski.com/ <https://ethanchlebowski.com>`_
Expand Down
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
from .eatingwell import EatingWell
from .eatsmarter import Eatsmarter
from .eattolerant import EatTolerant
from .eatwell101 import EatWell101
from .eatwhattonight import EatWhatTonight
from .emmikochteinfach import EmmiKochtEinfach
from .epicurious import Epicurious
Expand Down Expand Up @@ -341,6 +342,7 @@
DomesticateMe.host(): DomesticateMe,
Downshiftology.host(): Downshiftology,
Dr.host(): Dr,
EatWell101.host(): EatWell101,
EatWhatTonight.host(): EatWhatTonight,
EatingBirdFood.host(): EatingBirdFood,
EatingWell.host(): EatingWell,
Expand Down
64 changes: 64 additions & 0 deletions recipe_scrapers/eatwell101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# mypy: allow-untyped-defs

import html
import re

from ._abstract import AbstractScraper
from ._utils import normalize_string


class EatWell101(AbstractScraper):
@classmethod
def host(cls):
return "eatwell101.com"

def author(self):
return self.schema.author()

def title(self):
return self.schema.title()

def category(self):
return html.unescape(self.schema.category())

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

def ingredients(self):
ingredients_h2 = self.soup.find(
"h2", string=re.compile(r"Ingredients", re.IGNORECASE)
)
ingredients_ul = ingredients_h2.find_next("ul")
ingredients_list = [item.text.strip() for item in ingredients_ul.find_all("li")]
normalized_ingredients = [
normalize_string(ingredient) for ingredient in ingredients_list
]

return normalized_ingredients

def instructions(self):
directions_h2 = self.soup.find("h2", string="Directions")
instructions_list = []
if directions_h2:
next_sibling = directions_h2.find_next_sibling()
while next_sibling:
if next_sibling.name == "p" and next_sibling.find("strong"):
instruction_text = normalize_string(next_sibling.text.strip())
instructions_list.append(instruction_text)
next_sibling = next_sibling.find_next_sibling()
else:
break

return "\n".join(instructions_list)

def cuisine(self):
return self.schema.cuisine()

def description(self):
return self.soup.find("div", {"class": "saveurteaser"}).get_text()
5,295 changes: 5,295 additions & 0 deletions tests/test_data/eatwell101.testhtml

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions tests/test_eatwell101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# mypy: allow-untyped-defs

from recipe_scrapers.eatwell101 import EatWell101
from tests import ScraperTest


class TestEatWell101Scraper(ScraperTest):

scraper_class = EatWell101

def test_host(self):
self.assertEqual("eatwell101.com", self.harvester_class.host())

def test_author(self):
self.assertEqual("Christina Cherrier", self.harvester_class.author())

def test_title(self):
self.assertEqual(
"Creamy Spinach Turkey Meatballs", self.harvester_class.title()
)

def test_category(self):
self.assertEqual(
"Chicken, Cook, Cooking & Meals, main dish recipes, Poultry recipes, ",
self.harvester_class.category(),
)

def test_total_time(self):
self.assertEqual(40, self.harvester_class.total_time())

def test_yields(self):
self.assertEqual("4 servings", self.harvester_class.yields())

def test_image(self):
self.assertEqual(
"https://www.eatwell101.com/wp-content/uploads/2021/05/Creamy-Turkey-Meatballs-Recipe.jpg",
self.harvester_class.image(),
)

def test_ingredients(self):
expected_ingredients = [
"1/2 lb (220g) ground turkey meat",
"1/2 lb (220g) ground chicken meat",
"1/2 cup shredded mozzarella (or cheddar, provolone…)",
"4 cloves garlic, grated + 4 cloves garlic, minced",
"1 teaspoon Italian seasoning",
"1/2 teaspoon red crushed chili pepper flakes, optional",
"1 crumbled bouillon cube, optional",
"Salt and fresh cracked black pepper, to taste",
"1 cup fresh chopped cilantro (or parsley), divided",
"2 teaspoons olive oil",
"2 tablespoons butter",
"1 small yellow onion, diced",
"1/3 cup (80ml) vegetable broth",
"5 ounces (150g) jarred sun-dried tomato in oil, drained of oil",
"1 3/4 cups heavy cream",
"Salt and pepper, to taste",
"3 cups baby spinach leaves",
"1/2 cup grated Parmesan",
"1 tablespoon fresh parsley, chopped",
]

self.assertEqual(expected_ingredients, self.harvester_class.ingredients())

def test_instructions(self):
expected_instructions = (
"1. To make the creamy spinach turkey meatballs: In a large bowl, combine ground turkey and ground chicken, cheese, grated garlic, Italian seasoning, bouillon cube, red chili pepper flakes, chopped cilantro, and black pepper. Mix well with your hands or fork and form medium balls. Arrange the turkey meatballs on a plate and set them aside.\n"
"2. Melt 2 tablespoons butter in a large skillet over medium-low heat. Cook the turkey meatballs for 8 – 10 minutes on all sides until browned and cooked through. Remove to a clean plate and set aside.\n"
"3. In the same pan, melt the butter in the remaining cooking juices. Add in the garlic and fry until fragrant (about one minute). Add onion and stir fry until translucent. Add the sun-dried tomatoes and fry for 1-2 minutes, so they release their flavors. Finally, pour in the vegetable broth, and allow the sauce to reduce slightly.\n"
"4. Reduce heat to low, add in the heavy cream, and bring to a gentle simmer while stirring occasionally. Season the cream sauce with salt and pepper to taste.\n"
"5. Add in the baby spinach and allow to wilt in the sauce. Finally, add in the parmesan cheese. Allow cream sauce to simmer for a further minute until the cheese melts through.\n"
"6. Add the cooked turkey meatballs back into the pan; sprinkle with the parsley, and spoon the sauce over each meatball. Serve the creamy garlic spinach Tuscan meatballs over steamed veg or cauliflower rice for Keto dieters, or rice or pasta for non-Keto. Enjoy! ❤️"
)
self.assertEqual(expected_instructions, self.harvester_class.instructions())

def test_cuisine(self):
self.assertEqual("American", self.harvester_class.cuisine())

def test_description(self):
self.assertEqual(
"These turkey meatballs are Gluten-free, low-carb, and veto-friendly - Perfect for a crowd-pleasing weeknight dinner. The creamy spinach turkey and chicken meatballs just melt in your mouth, it's so good!",
self.harvester_class.description(),
)

0 comments on commit 88231b8

Please sign in to comment.