mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-09 16:18:00 -05:00
added cooksillustrated custom scraper
This commit is contained in:
@@ -4,12 +4,8 @@ from recipe_scrapers._abstract import AbstractScraper
|
|||||||
|
|
||||||
class CooksIllustrated(AbstractScraper):
|
class CooksIllustrated(AbstractScraper):
|
||||||
@classmethod
|
@classmethod
|
||||||
def host(cls, site='cooksillustrated'):
|
def host(cls):
|
||||||
return {
|
return "cooksillustrated.com"
|
||||||
'cooksillustrated': f"{site}.com",
|
|
||||||
'americastestkitchen': f"{site}.com",
|
|
||||||
'cookscountry': f"{site}.com",
|
|
||||||
}.get(site)
|
|
||||||
|
|
||||||
def title(self):
|
def title(self):
|
||||||
return self.schema.title()
|
return self.schema.title()
|
||||||
@@ -35,10 +31,10 @@ class CooksIllustrated(AbstractScraper):
|
|||||||
ingredients += group['fields']['recipeIngredientItems']
|
ingredients += group['fields']['recipeIngredientItems']
|
||||||
return [
|
return [
|
||||||
"{} {} {}{}".format(
|
"{} {} {}{}".format(
|
||||||
i['fields']['qty'] or '',
|
i['fields']['qty'],
|
||||||
i['fields']['measurement'] or '',
|
i['fields']['measurement'],
|
||||||
i['fields']['ingredient']['fields']['title'] or '',
|
i['fields']['ingredient']['fields']['title'],
|
||||||
i['fields']['postText'] or ''
|
i['fields']['postText']
|
||||||
)
|
)
|
||||||
for i in ingredients
|
for i in ingredients
|
||||||
]
|
]
|
||||||
@@ -46,17 +42,11 @@ class CooksIllustrated(AbstractScraper):
|
|||||||
def instructions(self):
|
def instructions(self):
|
||||||
if not self.recipe:
|
if not self.recipe:
|
||||||
self.get_recipe()
|
self.get_recipe()
|
||||||
if self.recipe.get('headnote', False):
|
return "\n".join([self.recipe['whyThisWorks']] +
|
||||||
i = ['Note: ' + self.recipe.get('headnote', '')]
|
[
|
||||||
else:
|
instruction['fields']['content']
|
||||||
i = []
|
for instruction in self.recipe['instructions']
|
||||||
return "\n".join(
|
]
|
||||||
i
|
|
||||||
+ [self.recipe.get('whyThisWorks', '')]
|
|
||||||
+ [
|
|
||||||
instruction['fields']['content']
|
|
||||||
for instruction in self.recipe['instructions']
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def nutrients(self):
|
def nutrients(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user