Skip to content

Commit

Permalink
Add support for kellyscleankitchen.com (#1425)
Browse files Browse the repository at this point in the history
* Add support for kellyscleankitchen.com

* Add test json file

* Update tests

* Update test and code based on feedback

Update recipe_scrapers/kellyscleankitchen.py

Co-authored-by: Joey <[email protected]>

Update recipe_scrapers/kellyscleankitchen.py

Co-authored-by: Joey <[email protected]>

Update recipe_scrapers/kellyscleankitchen.py

Co-authored-by: Joey <[email protected]>

Update recipe_scrapers/kellyscleankitchen.py

Co-authored-by: Joey <[email protected]>

Update recipe_scrapers/kellyscleankitchen.py

Co-authored-by: Joey <[email protected]>

Update test coverage

* Reverted README.rst

---------

Co-authored-by: Joey <[email protected]>
  • Loading branch information
ashiramin and jknndy authored Jan 14, 2025
1 parent f6f4b5b commit 3301d0e
Show file tree
Hide file tree
Showing 6 changed files with 2,043 additions and 0 deletions.
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,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 @@ -580,6 +581,7 @@
JoyTheBaker.host(): JoyTheBaker,
Jumbo.host(): Jumbo,
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

0 comments on commit 3301d0e

Please sign in to comment.