-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for kellyscleankitchen.com (#1425)
* 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
Showing
6 changed files
with
2,043 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
tests/test_data/kellyscleankitchen.com/kellyscleankitchen_1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Oops, something went wrong.