Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingredient grouping & equipment support for spendwithpennies #1331

Merged
merged 6 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions recipe_scrapers/spendwithpennies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
from ._abstract import AbstractScraper
from ._grouping_utils import group_ingredients
from ._utils import get_equipment


class SpendWithPennies(AbstractScraper):
@classmethod
def host(cls):
return "spendwithpennies.com"

def ingredient_groups(self):
return group_ingredients(
self.ingredients(),
self.soup,
".wprm-recipe-ingredient-group h4",
".wprm-recipe-ingredient",
)

def equipment(self):
equipment_container = self.soup.find(
"div", class_="wprm-recipe-equipment-container"
)
if equipment_container:
equipment_items = [
item.get_text()
for item in equipment_container.find_all(
"div", class_="wprm-recipe-equipment-name"
)
]
return get_equipment(equipment_items)
57 changes: 0 additions & 57 deletions tests/test_data/spendwithpennies.com/spendwithpennies.json

This file was deleted.

1,443 changes: 0 additions & 1,443 deletions tests/test_data/spendwithpennies.com/spendwithpennies.testhtml

This file was deleted.

54 changes: 54 additions & 0 deletions tests/test_data/spendwithpennies.com/spendwithpennies_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"author": "Holly Nilsson",
"canonical_url": "https://www.spendwithpennies.com/cranberry-jalapeno-dip/",
"site_name": "Spend With Pennies",
"host": "spendwithpennies.com",
"language": "en-US",
"title": "Cranberry Jalapeno Dip",
"ingredients": [
"4 ounces fresh cranberries",
"¼ cup granulated sugar",
"8 ounces cream cheese (softened)",
"½ cup sour cream",
"4 ounces diced jalapeños (drained)",
"1 green onion (finely chopped)",
"2 tablespoons chopped fresh cilantro"
],
"instructions_list": [
"In a small saucepan, bring cranberries, sugar, and 2 tablespoons water to a boil. Simmer for 8 to 10 minutes. Cool completely before using, the sauce will thicken as it cools.",
"In a medium bowl, beat the cream cheese and sour cream with a hand mixer on medium speed until fluffy.",
"Add the cranberry sauce, diced jalapenos, green onion, and cilantro.",
"Stir well to combine and refrigerate 30 minutes before serving."
],
"category": "Appetizer,Dip,Party Food",
"yields": "4 servings",
"description": "A perfect mix of sweet and spicy flavors in a light fluffy dip!",
"total_time": 55,
"cook_time": 15,
"prep_time": 10,
"cuisine": "American",
"equipment": [
"Saucepan",
"Hand Mixer"
],
"nutrients": {
"servingSize": "1 serving",
"calories": "326 kcal",
"fatContent": "25 g",
"saturatedFatContent": "14 g",
"unsaturatedFatContent": "7 g",
"carbohydrateContent": "22 g",
"sugarContent": "18 g",
"proteinContent": "5 g",
"sodiumContent": "189 mg",
"fiberContent": "2 g",
"cholesterolContent": "74 mg"
},
"image": "https://www.spendwithpennies.com/wp-content/uploads/2024/01/Cranberry-Jalapeno-Dip-SpendWithPennies-7.jpg",
"keywords": [
"best recipe",
"Cranberry Jalapeno Dip",
"easy",
"how to make"
]
}
1,339 changes: 1,339 additions & 0 deletions tests/test_data/spendwithpennies.com/spendwithpennies_1.testhtml

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions tests/test_data/spendwithpennies.com/spendwithpennies_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"author": "Holly Nilsson",
"canonical_url": "https://www.spendwithpennies.com/pear-salad/",
"site_name": "Spend With Pennies",
"host": "spendwithpennies.com",
"language": "en-US",
"title": "Pear Salad",
"ingredients": [
"¼ cup vegetable oil (or light tasting olive oil)",
"3 tablespoons fresh lemon juice",
"1 tablespoon Dijon mustard",
"1 tablespoon maple syrup",
"½ teaspoon garlic powder",
"⅛ teaspoon salt (or to taste )",
"⅛ teaspoon black pepper",
"8 cups mixed greens",
"1 cup chopped flat leaf parsley",
"½ red onion (thinly sliced)",
"2 ripe pears (sliced just before serving, or 4 canned pear halves)",
"¼ cup slivered almonds (toasted*)",
"¼ cup dried cranberries (optional)",
"2 oz crumbled blue cheese (or feta cheese)"
],
"ingredient_groups": [
{
"ingredients": [
"¼ cup vegetable oil (or light tasting olive oil)",
"3 tablespoons fresh lemon juice",
"1 tablespoon Dijon mustard",
"1 tablespoon maple syrup",
"½ teaspoon garlic powder",
"⅛ teaspoon salt (or to taste )",
"⅛ teaspoon black pepper"
],
"purpose": "Dressing"
},
{
"ingredients": [
"8 cups mixed greens",
"1 cup chopped flat leaf parsley",
"½ red onion (thinly sliced)",
"2 ripe pears (sliced just before serving, or 4 canned pear halves)",
"¼ cup slivered almonds (toasted*)",
"¼ cup dried cranberries (optional)",
"2 oz crumbled blue cheese (or feta cheese)"
],
"purpose": "Salad"
}
],
"instructions_list": [
"In a small jar with a lid, combine the vegetable oil, lemon juice, Dijon mustard, maple syrup, garlic powder, salt, and pepper. Shake until fully combined and refrigerate.",
"In a large bowl, combine the mixed greens, chopped parsley, and sliced red onion. Add ¼ cup of the dressing (or adjust to taste) and toss to coat.",
"Cut the ripe pears in half lengthwise. Use a spoon or small knife to remove the core and seeds. Slice the pears into thin ⅛-inch slices.",
"Arrange the sliced pears on top of the salad. Sprinkle with toasted slivered almonds, dried cranberries, and crumbled blue cheese.",
"Drizzle additional dressing over the salad if desired.",
"Serve immediately."
],
"category": "Appetizer,Dressing,Lunch,Salad,Side Dish",
"yields": "4 servings",
"description": "This pear salad recipe is easy to prepare and looks elegant. Use fresh or canned pears in this recipe.",
"total_time": 20,
"prep_time": 20,
"cuisine": "American",
"ratings": 5.0,
"ratings_count": 9,
"equipment": [
"Salad Bowl",
"Mason Jars small jar with lid"
],
"nutrients": {
"servingSize": "1 serving",
"calories": "326 kcal",
"fatContent": "22 g",
"saturatedFatContent": "5 g",
"unsaturatedFatContent": "16 g",
"transFatContent": "0.1 g",
"carbohydrateContent": "31 g",
"sugarContent": "19 g",
"proteinContent": "7 g",
"sodiumContent": "309 mg",
"fiberContent": "5 g",
"cholesterolContent": "11 mg"
},
"image": "https://www.spendwithpennies.com/wp-content/uploads/2023/08/Pear-Salad-SpendWithPennies-2.jpg",
"keywords": [
"pear salad",
"pear salad dressing",
"pear salad recipe",
"pear salad with feta or blue cheese",
"pear salad with walnut and blue cheese"
]
}
Loading
Loading