Skip to content

Commit

Permalink
Add LeanAndGreenRecipes (#636)
Browse files Browse the repository at this point in the history
* feat: add LeanAndGreenRecipes

* fix: content parsing
  • Loading branch information
wengtad committed Oct 15, 2022
1 parent e1bfb74 commit 4326635
Show file tree
Hide file tree
Showing 5 changed files with 1,667 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rst
Expand Up @@ -191,6 +191,7 @@ Scrapers available for:
- `https://kuchnia-domowa.pl/ <https://www.kuchnia-domowa.pl/>`_
- `https://www.kwestiasmaku.com/ <https://www.kwestiasmaku.com/>`_
- `https://www.latelierderoxane.com <https://www.latelierderoxane.com/blog/recettes/>`_
- `https://leanandgreenrecipes.net <https://leanandgreenrecipes.net>`_
- `https://lecremedelacrumb.com/ <https://lecremedelacrumb.com/>`_
- `https://www.lecker.de <https://www.lecker.de/rezepte>`_
- `https://lekkerensimpel.com <https://lekkerensimpel.com>`_
Expand Down
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Expand Up @@ -113,6 +113,7 @@
from .kuchniadomowa import KuchniaDomowa
from .kwestiasmaku import KwestiaSmaku
from .latelierderoxane import LAtelierDeRoxane
from .leanandgreenrecipes import LeanAndGreenRecipes
from .lecker import Lecker
from .lecremedelacrumb import LeCremeDeLaCrumb
from .lekkerensimpel import LekkerEnSimpel
Expand Down Expand Up @@ -332,6 +333,7 @@
KwestiaSmaku.host(): KwestiaSmaku,
LAtelierDeRoxane.host(): LAtelierDeRoxane,
LeCremeDeLaCrumb.host(): LeCremeDeLaCrumb,
LeanAndGreenRecipes.host(): LeanAndGreenRecipes,
Lecker.host(): Lecker,
LekkerEnSimpel.host(): LekkerEnSimpel,
LittleSpiceJar.host(): LittleSpiceJar,
Expand Down
53 changes: 53 additions & 0 deletions recipe_scrapers/leanandgreenrecipes.py
@@ -0,0 +1,53 @@
# mypy: allow-untyped-defs

from bs4 import BeautifulSoup

from ._abstract import AbstractScraper
from ._utils import normalize_string


class LeanAndGreenRecipes(AbstractScraper):
@classmethod
def host(cls):
return "leanandgreenrecipes.net"

def author(self):
return self.schema.author()

def title(self):
return self.schema.title()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

def ingredients(self):
return self.schema.ingredients()

def instructions(self):
instructions = (
self.soup.find("div", {"class": "item-list"}).find_next("ol").find_all("li")
)
return "\n".join(
[normalize_string(instruction.get_text()) for instruction in instructions]
)

def ratings(self):
return self.schema.ratings()

def cuisine(self):
soup = BeautifulSoup(str(self.schema.cuisine()), features="html.parser")
return soup.get_text()

def description(self):
descriptions = self.soup.find(
"div", {"class": "block-field-blocknoderecipebody"}
).find_all("p")
return "\n".join(
[normalize_string(description.get_text()) for description in descriptions]
)

0 comments on commit 4326635

Please sign in to comment.