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

Add support for kellyscleankitchen.com #1425

Merged
merged 6 commits into from
Jan 14, 2025
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
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
from .justbento import JustBento
from .justonecookbook import JustOneCookbook
from .kalejunkie import KaleJunkie
from .kellyscleankitchen import KellysCleanKitchen
from .kennymcgovern import KennyMcGovern
from .keukenliefdenl import KeukenLiefdeNL
from .kingarthur import KingArthur
Expand Down Expand Up @@ -573,6 +574,7 @@
JoshuaWeissman.host(): JoshuaWeissman,
JoyTheBaker.host(): JoyTheBaker,
KaleJunkie.host(): KaleJunkie,
KellysCleanKitchen.host(): KellysCleanKitchen,
KitchenAidAustralia.host(): KitchenAidAustralia,
KitchenDivas.host(): KitchenDivas,
KitchenDreaming.host(): KitchenDreaming,
Expand Down
72 changes: 72 additions & 0 deletions recipe_scrapers/kellyscleankitchen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import re

from ._abstract import AbstractScraper
from ._utils import get_minutes, get_yields, normalize_string


class KellysCleanKitchen(AbstractScraper):
@classmethod
def host(cls):
return "kellyscleankitchen.com"

def title(self):
return normalize_string(
self.soup.find("h1", class_="fusion-post-title").get_text()
)

def total_time(self):
total_time_element = self.soup.find(
"span", class_="white-text", string=re.compile("TOTAL TIME")
)
if total_time_element:
total_time = total_time_element.get_text().split(":")[1]
return get_minutes(total_time)

def yields(self):
servings_element = self.soup.find(
"div", class_="fusion-li-item-content", string=re.compile("SERVINGS")
)
if servings_element:
servings = servings_element.get_text().split(":")[1]
return get_yields(servings)

def ingredients(self):
ingredients_list = []
ingredients_section = self.soup.find(
"h3", id=re.compile("ingredients.*")
).find_next("ul")
if ingredients_section:
ingredients = ingredients_section.find_all("li")
ingredients_list = [
normalize_string(ingredient.get_text()) for ingredient in ingredients
]
return ingredients_list

def instructions(self):
instructions_list = []
steps = self.soup.find_all(class_="recipe-steps")
for step in steps:
instruction_text = normalize_string(step.find_next("p").get_text())
if instruction_text:
instructions_list.append(instruction_text)
return "\n".join(instructions_list)

def prep_time(self):
prep_time_element = self.soup.find(
"span", class_="white-text", string=re.compile("PREP TIME")
)
if prep_time_element:
prep_time = prep_time_element.get_text().split(":")[1]
return get_minutes(prep_time)

def cook_time(self):
cook_time_element = self.soup.find(
"span", class_="white-text", string=re.compile("COOK TIME")
)
if cook_time_element:
cook_time = cook_time_element.get_text().split(":")[1]
return get_minutes(cook_time)

def description(self):
description_text = self.soup.find("h1").find_next("p")
return normalize_string(description_text.get_text()) if description_text else ""
28 changes: 28 additions & 0 deletions tests/test_data/kellyscleankitchen.com/kellyscleankitchen_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"canonical_url": "https://kellyscleankitchen.com/2024/11/29/protein-pumpkin-pie/",
"site_name": "Kelly's Clean Kitchen",
"host": "kellyscleankitchen.com",
"language": "en-US",
"title": "Protein Pumpkin Pie",
"ingredients": [
"3 large eggs",
"1.5 cups heavy cream",
"2 scoops Isopure Unflavored Protein Powder",
"1/2 tsp salt",
"3 tsp pumpkin pie spice",
"1/3 cup granulated sugar",
"1 pie crust, can be frozen or homemade, I used a frozen one here for ease"
],
"instructions_list": [
"Preheat the oven to 450°F.",
"Whisk together the eggs, heavy cream, protein powder, pumpkin pie spice and sugar until smooth.",
"Pour the pumpkin filling into a crust and bake at 450°F for 10 minutes. Reduce the temperature to 350°F and finish baking for 40-45 minutes. The pie is done when there is a gentle wiggle in the middle, but the edges are set.",
"Remove and cool to room temperature. Then transfer to the fridge and set for 2-3 hours.",
"Slice and serve, enjoy!"
],
"yields": "8 servings",
"total_time": 60,
"cook_time": 40,
"prep_time": 20,
"image": "https://kellyscleankitchen.com/wp-content/uploads/2024/11/Isopure-Pumpkin-Pie-11.jpg"
}
Loading