Skip to content
Open
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 @@ -314,6 +314,7 @@
from .justbento import JustBento
from .justinesnacks import JustineSnacks
from .justonecookbook import JustOneCookbook
from .kalcirecept import KalciRecept
from .kalejunkie import KaleJunkie
from .kellyscleankitchen import KellysCleanKitchen
from .kennethtemple import KennethTemple
Expand Down Expand Up @@ -946,6 +947,7 @@
JustBento.host(): JustBento,
JustineSnacks.host(): JustineSnacks,
JustOneCookbook.host(): JustOneCookbook,
KalciRecept.host(): KalciRecept,
KaleJunkie.host(): KaleJunkie,
KellysCleanKitchen.host(): KellysCleanKitchen,
KennethTemple.host(): KennethTemple,
Expand Down
74 changes: 74 additions & 0 deletions recipe_scrapers/kalcirecept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from ._abstract import AbstractScraper
from ._utils import normalize_string


class KalciRecept(AbstractScraper):
@classmethod
def host(cls):
return "kalcirecept.hu"

def site_name(self):
og_site_name = self.soup.find("meta", {"property": "og:site_name"})
if og_site_name:
return og_site_name.get("content", "")
return "Kálci receptjei"

def title(self):
h1 = self.soup.find("h1", class_="text-white")
if h1:
return normalize_string(h1.get_text())
og_title = self.soup.find("meta", {"property": "og:title"})
if og_title:
title = og_title.get("content", "")
sep = title.rfind(" - ")
if sep != -1:
title = title[:sep]
return normalize_string(title)
return None

def image(self):
og_image = self.soup.find("meta", {"property": "og:image"})
if og_image:
return og_image.get("content", "")
return None

def _find_heading(self, text):
for h1 in self.soup.find_all("h1"):
if h1.get_text(strip=True) == text:
return h1
return None

def ingredients(self):
heading = self._find_heading("Hozzávalók")
if not heading:
return []
container = heading.find_next_sibling()
if not container:
return []
ingredients = []
for li in container.find_all("li"):
spans = li.find_all("span")
if spans:
parts = [
normalize_string(s.get_text())
for s in spans
if s.get_text(strip=True)
]
text = " ".join(parts)
if text:
ingredients.append(text)
return ingredients

def instructions(self):
heading = self._find_heading("A recept")
if not heading:
return ""
container = heading.find_next_sibling()
if not container:
return ""
steps = []
for p in container.find_all("p"):
text = normalize_string(p.get_text())
if text:
steps.append(text)
return "\n".join(steps)
22 changes: 22 additions & 0 deletions tests/test_data/kalcirecept.hu/kalcirecept.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"canonical_url": "https://www.kalcirecept.hu/hu/receptek/csokis-kuglof",
"site_name": "Kálci receptjei",
"host": "kalcirecept.hu",
"language": "hu",
"title": "Csokis kuglóf",
"ingredients": [
"4 db tojás (M-es)",
"250 g porcukor",
"1 csomag (8 g) vaníliás cukor",
"1 dl (100 g) tehéntej (2,8%)",
"1 dl (92 g) napraforgóolaj",
"150 g búzafinomliszt (BL 55)",
"50 g (5 ek) holland kakaópor",
"1/2 csomag (6 g) sütőpor",
"1 tábla (90-100 g) étcsokoládé"
],
"instructions_list": [
"A tojásokat szétválasztjuk. A sárgáját a porcukorral és a vaníliás cukorral a tej hozzáadásával habosra keverjük, majd belecsorgatjuk az olajat és egyneműre keverjük. A tojásfehérjét külön edényben kemény habbá verjük, majd óvatos mozdulatokkal összeforgatjuk a sárgás masszával. A lisztet, a kakaóport és a sütőport összekeverjük, ezt is a tésztához forgatjuk, végül hozzáadjuk az apróra vágott étcsokoládét. A masszát kivajazott, kilisztezett kuglófformába öntjük, majd 180 fokra előmelegített sütőben 50 percig sütjük, a végén tűpróbával ellenőrizzük."
],
"image": "https://www.kalcirecept.hu/uploads/01KFKKBA2A56N63AFB95109YGD.png"
}
Loading