-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# mypy: allow-untyped-defs | ||
import re | ||
|
||
from ._abstract import AbstractScraper | ||
from ._utils import get_minutes, get_yields | ||
|
||
|
||
class Aldi(AbstractScraper): | ||
@classmethod | ||
def host(cls): | ||
return "aldi.com.au" | ||
|
||
def site_name(self): | ||
return "Aldi" | ||
|
||
def author(self): | ||
return self.soup.find("meta", {"name": "author"}).get("content") | ||
|
||
def title(self): | ||
return self.soup.find("h1").text | ||
|
||
def category(self): | ||
element = self.soup.select_one("a.tab-nav--link.dropdown--list--link.m-active") | ||
if element: | ||
title = element.text | ||
recipe_position = title.find(" Recipe") | ||
if recipe_position != -1: | ||
return title[:recipe_position] | ||
|
||
def prep_time(self): | ||
return get_minutes(self._get_value(re.compile("prep", re.IGNORECASE))) | ||
|
||
def cook_time(self): | ||
return get_minutes(self._get_value(re.compile("cook", re.IGNORECASE))) | ||
|
||
def total_time(self): | ||
return (self.prep_time() or 0) + (self.cook_time() or 0) | ||
|
||
def yields(self): | ||
value = self._get_value(re.compile("(makes)|(serves)", re.IGNORECASE)) | ||
return get_yields(str(value)) | ||
|
||
def image(self): | ||
figure = self.soup.find("figure", {"class": "csc-textpic-image csc-textpic-last"}) | ||
if figure: | ||
image = figure.find("img") | ||
if image: | ||
return image.get("src") | ||
return None | ||
|
||
def ingredients(self): | ||
h2 = self.soup.find("h2", string=re.compile("Ingredients")) | ||
list_element = h2.find_next_sibling("ul") | ||
ingredients = [] | ||
for li in list_element.find_all("li"): | ||
ingredients.append(li.text.strip()) | ||
return ingredients | ||
|
||
def instructions(self): | ||
list_element = self.soup.find("ol") | ||
return "\n".join(li.text.strip() for li in list_element.find_all("li")) | ||
|
||
def _get_value(self, label): | ||
label_element = self.soup.find("b", string=label) | ||
if label_element: | ||
parts = [sibling.strip() for sibling in label_element.find_next_siblings(string=True) if sibling.strip()] | ||
return " ".join(parts) | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"author": "ALDI AU", | ||
"canonical_url": "https://www.aldi.com.au/recipes/breakfast-recipes/overloaded-cheese-toastie-recipe/", | ||
"host": "aldi.com.au", | ||
"image": "https://www.aldi.com.au/fileadmin/_processed_/8/b/csm_1000340_WK23_PD_455x315__OVERLOADED-CHEESE-TOASTIE__1_RET_4506d46579.jpg", | ||
"category": "Breakfast", | ||
"ingredients": [ | ||
"1 tbsp Remano pesto", | ||
"1 slice Westacre tasty cheese", | ||
"3 slices tomato", | ||
"2 slices sourdough bread", | ||
"Handful of The Fresh Salad Co baby spinach" | ||
], | ||
"ingredient_groups": [ | ||
{ | ||
"purpose": null, | ||
"ingredients": [ | ||
"1 tbsp Remano pesto", | ||
"1 slice Westacre tasty cheese", | ||
"3 slices tomato", | ||
"2 slices sourdough bread", | ||
"Handful of The Fresh Salad Co baby spinach" | ||
] | ||
} | ||
], | ||
"instructions": "Preheat a sandwich press.\nSpread pesto on one slice of bread and layer with cheese, tomato and spinach and close the sandwich with the remaining slice of bread.\nPlace the sandwich in the press and cook for 3-4 minutes or until the cheese melts and the sandwich is golden brown.\nAllow to cool slightly before serving.", | ||
"instructions_list": [ | ||
"Preheat a sandwich press.", | ||
"Spread pesto on one slice of bread and layer with cheese, tomato and spinach and close the sandwich with the remaining slice of bread.", | ||
"Place the sandwich in the press and cook for 3-4 minutes or until the cheese melts and the sandwich is golden brown.", | ||
"Allow to cool slightly before serving." | ||
], | ||
"language": "en-AU", | ||
"site_name": "Aldi", | ||
"title": "Overloaded Cheese Toastie Recipe", | ||
"prep_time": 5, | ||
"cook_time": 5, | ||
"total_time": 10, | ||
"yields": "1 serving" | ||
} |
Oops, something went wrong.