Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LeanAndGreenRecipes #636

Merged
merged 2 commits into from Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -331,6 +332,7 @@
KwestiaSmaku.host(): KwestiaSmaku,
LAtelierDeRoxane.host(): LAtelierDeRoxane,
LeCremeDeLaCrumb.host(): LeCremeDeLaCrumb,
LeanAndGreenRecipes.host(): LeanAndGreenRecipes,
Lecker.host(): Lecker,
LekkerEnSimpel.host(): LekkerEnSimpel,
LittleSpiceJar.host(): LittleSpiceJar,
Expand Down
51 changes: 51 additions & 0 deletions recipe_scrapers/leanandgreenrecipes.py
@@ -0,0 +1,51 @@
# mypy: allow-untyped-defs

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):
cuisine = self.schema.cuisine()
return cuisine[cuisine.find(">") + 1 :].replace("</a>", "")

def description(self):
return (
self.schema.description()
.replace("</p> <p>", "\n")
.replace("<p>", "")
.replace("</p>", "")
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: are you able to find any counter-example recipes that do not require this kind of escaping of the schema description (and/or recipeCuisine field)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for reviewing, provided a fix, please check.

: wonder how to add the hacktoberfest-accepted label into this merge request?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remember you @wengtad and will attach hacktoberfest-accepted labels to your PRs through October 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!