-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for okokorecepten (#1464)
- Loading branch information
Showing
6 changed files
with
1,397 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,64 @@ | ||
from ._abstract import AbstractScraper | ||
from ._grouping_utils import IngredientGroup | ||
|
||
|
||
class OkokoRecepten(AbstractScraper): | ||
@classmethod | ||
def host(cls): | ||
return "okokorecepten.nl" | ||
|
||
def instructions(self): | ||
instructions = [] | ||
|
||
voorbereiden_section = self.soup.find( | ||
"h2", string=lambda text: "Voorbereiden" in text | ||
) | ||
if voorbereiden_section: | ||
for sibling in voorbereiden_section.find_next_siblings(): | ||
if sibling.name == "h2": | ||
break | ||
if sibling.name == "p": | ||
instructions.append(sibling.get_text(strip=True)) | ||
|
||
bereiden_section = self.soup.find("h2", string=lambda text: "Bereiden" in text) | ||
if bereiden_section: | ||
for sibling in bereiden_section.find_next_siblings(): | ||
if sibling.name == "h2": | ||
break | ||
if sibling.name == "p": | ||
instructions.append(sibling.get_text(strip=True)) | ||
|
||
return "\n".join(instructions) | ||
|
||
def ingredient_groups(self): | ||
ingredient_groups = [] | ||
ingredients_section = self.soup.find( | ||
"h2", string=lambda text: "Ingrediënten" in text | ||
) | ||
if not ingredients_section: | ||
return None | ||
|
||
current_group = {"purpose": None, "ingredients": []} | ||
|
||
for sibling in ingredients_section.find_next_siblings(): | ||
if sibling.name == "h2": | ||
break | ||
if sibling.name == "ul": | ||
for li in sibling.find_all("li"): | ||
if "tussenkop" in li.get("class", []): | ||
if current_group["ingredients"]: | ||
ingredient_groups.append(current_group) | ||
current_group = { | ||
"purpose": li.get_text(strip=True), | ||
"ingredients": [], | ||
} | ||
else: | ||
current_group["ingredients"].append(li.get_text(strip=True)) | ||
|
||
if current_group["ingredients"]: | ||
ingredient_groups.append(current_group) | ||
|
||
return [ | ||
IngredientGroup(ingredients=group["ingredients"], purpose=group["purpose"]) | ||
for group in ingredient_groups | ||
] |
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,48 @@ | ||
{ | ||
"author": "okoko recepten", | ||
"canonical_url": "okokorecepten.nl", | ||
"site_name": "okoko recepten", | ||
"host": "okokorecepten.nl", | ||
"language": "nl", | ||
"title": "Zuurkoolsoep", | ||
"ingredients": [ | ||
"2 eetlepels olie", | ||
"1 grote ui, gesnipperd", | ||
"200 g zuurkool, uitgelekt en fijngesneden", | ||
"½ blikje tomaatstukjes", | ||
"2 theelepels tijm", | ||
"2 kippenbouillontabletten", | ||
"2 plakjes kipfilet (vleeswaar), in dunne reepjes", | ||
"2 takjes basilicum, in fijne reepjes" | ||
], | ||
"category": "Voorgerecht", | ||
"yields": "4 servings", | ||
"description": "Zuurkoolsoep. Kijk voor de bereidingswijze op okokorecepten.nl.", | ||
"total_time": 30, | ||
"cook_time": 30, | ||
"cuisine": "Hollands", | ||
"ratings": 7.9, | ||
"ratings_count": 18, | ||
"nutrients": { | ||
"calories": "75 kcal", | ||
"fatContent": "5 g vet", | ||
"carbohydrateContent": "4 g koolhydraten", | ||
"proteinContent": "4 g eiwit" | ||
}, | ||
"image": "https://www.okokorecepten.nl/i/recepten/redactie/2009-2/zuurkoolsoep-500.jpg", | ||
"keywords": [ | ||
"recept", | ||
"zuurkoolsoep", | ||
"hollands", | ||
"voorgerecht", | ||
"gevogelte", | ||
"olie", | ||
"ui", | ||
"zuurkool", | ||
"tomaatstukjes", | ||
"tijm", | ||
"kippenbouillontablet", | ||
"kipfilet", | ||
"basilicum" | ||
] | ||
} |
Oops, something went wrong.