Skip to content

Commit

Permalink
Merge branch 'main' into v14
Browse files Browse the repository at this point in the history
Conflicts:
	recipe_scrapers/__init__.py
	recipe_scrapers/americastestkitchen.py
	tests/test_data/americastestkitchen.com/americastestkitchen.json
	tests/test_data/cookscountry.com/cookscountry.json
	tests/test_data/cooksillustrated.com/cooksillustrated.json
  • Loading branch information
jayaddison committed Aug 30, 2024
2 parents 28934e4 + 121060a commit 4c8eaa7
Show file tree
Hide file tree
Showing 492 changed files with 1,258 additions and 1,726 deletions.
1 change: 0 additions & 1 deletion docs/how-to-develop-scraper.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ The generated json file will look something like this, with only the host field
"language": "",
"title": "",
"ingredients": "",
"instructions": "",
"instructions_list": "",
"total_time": "",
"yields": "",
Expand Down
1 change: 0 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def generate_scraper_test(class_name, host_name):
"language": "",
"title": "",
"ingredients": "",
"instructions": "",
"instructions_list": "",
"total_time": "",
"yields": "",
Expand Down
6 changes: 5 additions & 1 deletion recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from typing import Any

from ._abstract import AbstractScraper
from ._exceptions import NoSchemaFoundInWildMode, WebsiteNotImplementedError
from ._exceptions import (
NoSchemaFoundInWildMode,
RecipeSchemaNotFound,
WebsiteNotImplementedError,
)
from ._factory import SchemaScraperFactory
from ._utils import get_host_name
from .aberlehome import AberleHome
Expand Down
9 changes: 9 additions & 0 deletions recipe_scrapers/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class SchemaOrgException(FillPluginException):
...


class RecipeSchemaNotFound(SchemaOrgException):
"""No recipe schema metadata found on the page"""

def __init__(self, url):
self.url = url
message = f"No Recipe Schema found at {self.url}."
super().__init__(message)


class StaticValueException(RecipeScrapersExceptions):
"""Error to communicate that the scraper is returning a fixed/static value."""

Expand Down
17 changes: 17 additions & 0 deletions recipe_scrapers/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,20 @@ def get_abstract_methods():
and name not in {"links", "to_json"} # ... and not excluded as special-cases.
or name == "host" # ... explicitly include the `host` method.
]


def get_nutrition_keys():
return [
"servingSize",
"calories",
"fatContent",
"saturatedFatContent",
"unsaturatedFatContent",
"transFatContent",
"carbohydrateContent",
"sugarContent",
"proteinContent",
"sodiumContent",
"fiberContent",
"cholesterolContent",
]
3 changes: 0 additions & 3 deletions recipe_scrapers/bakels.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def author(self):
def title(self):
return self.soup.find("h1").get_text()

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

def ingredients(self):
div = self.soup.find("div", id="tab-ingredients_1")
if not div:
Expand Down
3 changes: 0 additions & 3 deletions recipe_scrapers/bigoven.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ def ingredient_groups(self):
def instructions(self):
ps = self.soup.find("div", {"class": "instructions"}).findAll("p")
return "\n".join([normalize_string(p.text) for p in ps])

def ratings(self):
return self.schema.ratings()
3 changes: 0 additions & 3 deletions recipe_scrapers/chefnini.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ def author(self):
def title(self):
return self.soup.find("span", {"itemprop": "headline"}).get_text()

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

def total_time(self):
raise FieldNotProvidedByWebsiteException(return_value=None)

Expand Down
5 changes: 1 addition & 4 deletions recipe_scrapers/cookinglight.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from ._abstract import AbstractScraper
from ._utils import get_yields, normalize_string
from ._utils import normalize_string


class CookingLight(AbstractScraper):
@classmethod
def host(cls):
return "cookinglight.com"

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

def ingredients(self):
ingredients = self.soup.find("div", {"class": "ingredients"}).ul.findAll("li")
return "\n".join(
Expand Down
30 changes: 0 additions & 30 deletions recipe_scrapers/dobruchutaktualitysk.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ def keywords(self):
# site has no support for recipe keywords
raise FieldNotProvidedByWebsiteException(return_value=None)

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

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

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

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):
p_list = self.soup.find("div", {"class": "procedure-list"}).findChildren("p")

Expand All @@ -44,15 +23,6 @@ def instructions(self):

return "\n".join(instructions)

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

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

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

def ingredient_groups(self):
return group_ingredients(
self.ingredients(),
Expand Down
3 changes: 0 additions & 3 deletions recipe_scrapers/felixkitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ def yields(self):
yields_strong = container_p.find("strong")
return yields_strong.text

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

def ingredients(self):
ingredients = []

Expand Down
21 changes: 0 additions & 21 deletions recipe_scrapers/fifteengram.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,3 @@ def canonical_url(self):

def author(self):
return "15gram"

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):
return self.schema.instructions()

def description(self):
return self.schema.description()
30 changes: 0 additions & 30 deletions recipe_scrapers/gourmettraveller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ class GourmetTraveller(AbstractScraper):
def host(cls):
return "gourmettraveller.com.au"

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

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

def category(self):
recipe_category_span = self.soup.find(
"span", {"class": "related-tags__label"}, string=re.compile("Recipe Course")
Expand All @@ -25,21 +19,6 @@ def category(self):
value = recipe_category_span.find_next_sibling("span")
return normalize_string(value.text)

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

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

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

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

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

def ingredients(self):
group_heading_divs = self.soup.find_all(
"div", {"class": "recipe-ingredients__title"}
Expand All @@ -58,15 +37,6 @@ def ingredients(self):

return ingredients

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

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

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

def ingredient_groups(self):
return group_ingredients(
self.ingredients(),
Expand Down
3 changes: 0 additions & 3 deletions recipe_scrapers/halfbakedharvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ class HalfBakedHarvest(AbstractScraper):
def host(cls):
return "halfbakedharvest.com"

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

def ingredient_groups(self):
return group_ingredients(
self.ingredients(),
Expand Down
3 changes: 0 additions & 3 deletions recipe_scrapers/hellofresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ def total_time(self):
prep_time, cook_time = self.prep_time(), self.cook_time()
if prep_time or cook_time:
return (prep_time or 0) + (cook_time or 0)

def nutrients(self):
return self.schema.nutrients()
3 changes: 0 additions & 3 deletions recipe_scrapers/jamieoliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ class JamieOliver(AbstractScraper):
def host(cls):
return "jamieoliver.com"

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

def instructions(self):
instructions = self.soup.find("ol", {"class": "recipeSteps"}).findAll("li")
return "\n".join([normalize_string(inst.get_text()) for inst in instructions])
36 changes: 0 additions & 36 deletions recipe_scrapers/jocooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@ class JoCooks(AbstractScraper):
def host(cls):
return "jocooks.com"

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

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

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

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 ingredient_groups(self):
return group_ingredients(
self.ingredients(),
Expand All @@ -37,21 +16,6 @@ def ingredient_groups(self):
".wprm-recipe-ingredient",
)

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

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

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

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

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

def equipment(self):
equipment_items = [
item.get_text()
Expand Down
39 changes: 0 additions & 39 deletions recipe_scrapers/kitchensanctuary.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,6 @@ class KitchenSanctuary(AbstractScraper):
def host(cls):
return "kitchensanctuary.com"

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

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

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

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

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

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

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

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

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

def ingredient_groups(self):
ingredient_groups = self.soup.find_all(
"div", {"class": "wprm-recipe-ingredient-group"}
Expand Down Expand Up @@ -68,15 +41,3 @@ def ingredient_groups(self):
ingredient_index_base = ingredient_count

return results

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

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

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

def description(self):
return self.schema.description()
3 changes: 0 additions & 3 deletions recipe_scrapers/lekkerensimpel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ def title(self):
title = self.soup.find("h1", {"class": "hero__title"}).text
return normalize_string(title)

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

def image(self):
image = self.soup.find("meta", {"property", "og:image"})
return image["content"] if image else None
Expand Down
Loading

0 comments on commit 4c8eaa7

Please sign in to comment.