Skip to content

Commit

Permalink
Adding canonical_url for all scrapers & associated updates: batch four (
Browse files Browse the repository at this point in the history
  • Loading branch information
jknndy authored Oct 29, 2023
1 parent 15ad3f9 commit bfe0c9e
Show file tree
Hide file tree
Showing 162 changed files with 107,871 additions and 104,921 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ Scrapers available for:
- `https://thekitchn.com/ <https://thekitchn.com/>`_
- `https://www.themagicalslowcooker.com/ <https://www.themagicalslowcooker.com/>`_
- `https://themodernproper.com/ <https://themodernproper.com/>`_
- `https://thenutritiouskitchen.co/ <https://thenutritiouskitchen.co/>`_
- `https://thepioneerwoman.com/ <https://thepioneerwoman.com>`_
- `https://therecipecritic.com/ <https://therecipecritic.com>`_
- `https://thespruceeats.com/ <https://thespruceeats.com/>`_
Expand Down
2 changes: 0 additions & 2 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@
from .thekitchn import TheKitchn
from .themagicalslowcooker import TheMagicalSlowCooker
from .themodernproper import TheModernProper
from .thenutritiouskitchen import TheNutritiousKitchen
from .thepioneerwoman import ThePioneerWoman
from .therecipecritic import Therecipecritic
from .thespruceeats import TheSpruceEats
Expand Down Expand Up @@ -564,7 +563,6 @@
TheKitchn.host(): TheKitchn,
TheMagicalSlowCooker.host(): TheMagicalSlowCooker,
TheModernProper.host(): TheModernProper,
TheNutritiousKitchen.host(): TheNutritiousKitchen,
ThePioneerWoman.host(): ThePioneerWoman,
TheSpruceEats.host(): TheSpruceEats,
TheVintageMixer.host(): TheVintageMixer,
Expand Down
22 changes: 21 additions & 1 deletion recipe_scrapers/southernliving.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# mypy: disallow_untyped_defs=False

from recipe_scrapers._exceptions import SchemaOrgException

from ._abstract import AbstractScraper
from ._utils import get_yields


class SouthernLiving(AbstractScraper):
Expand All @@ -15,7 +18,24 @@ def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()
try:
schema_yield = self.schema.yields()
if schema_yield:
return schema_yield
except SchemaOrgException:
pass

for servings_div in self.soup.find_all(
"div", class_="mntl-recipe-details__item"
):
label_text = servings_div.find(
"div", class_="mntl-recipe-details__label"
).get_text(strip=True)
if label_text in ["Servings:", "Yield:"]:
servings_element = servings_div.find(
"div", class_="mntl-recipe-details__value"
)
return get_yields(servings_element)

def image(self):
return self.schema.image()
Expand Down
8 changes: 5 additions & 3 deletions recipe_scrapers/sweetpeasandsaffron.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mypy: disallow_untyped_defs=False
from ._abstract import AbstractScraper
from ._utils import normalize_string
from ._utils import get_minutes, get_yields, normalize_string


class SweetPeasAndSaffron(AbstractScraper):
Expand All @@ -16,10 +16,12 @@ def title(self):
return self.soup.find("h2", {"class": "wprm-recipe-name"}).text

def total_time(self):
return self.soup.find("span", {"class": "wprm-recipe-total_time"}).text
time = self.soup.find("span", {"class": "wprm-recipe-total_time"}).text
return get_minutes(time)

def yields(self):
return self.soup.find("span", {"class": "wprm-recipe-servings"}).text
servings = self.soup.find("span", {"class": "wprm-recipe-servings"}).text
return get_yields(servings)

def image(self):
return self.soup.find(
Expand Down
26 changes: 0 additions & 26 deletions recipe_scrapers/thenutritiouskitchen.py

This file was deleted.

20 changes: 14 additions & 6 deletions recipe_scrapers/zeitwochenmarkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ def image(self):
return self.schema.image()

def ingredients(self):
class_name = "recipe-list-collection__special-ingredient"
special_ingredients = [
normalize_string(item.text)
for item in self.soup.find_all("p", {"class": class_name})
]
return special_ingredients + self.schema.ingredients()
ingredients = []
for div_element in self.soup.select(".recipe-list-collection"):
special_ingredients = div_element.select(
".recipe-list-collection__special-ingredient"
)
ingredients.extend(normalize_string(p.text) for p in special_ingredients)

list_items = div_element.select(".recipe-list-collection__list li")
ingredients.extend(
normalize_string(li.get_text(strip=True, separator=" "))
for li in list_items
)

return ingredients

def instructions(self):
class_name = "article__subheading article__subheading--recipe article__item"
Expand Down
Loading

0 comments on commit bfe0c9e

Please sign in to comment.