/
simplycookit.py
50 lines (35 loc) · 1.22 KB
/
simplycookit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from ._abstract import AbstractScraper
from ._utils import normalize_string
class SimplyCookit(AbstractScraper):
@classmethod
def host(cls):
return "simply-cookit.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):
ingredients = []
for li in self.soup.find("ul", {"class": "recipe_ingredients"}).findAll("li"):
ingredients.append(normalize_string(li.get_text()))
return ingredients
def instructions(self):
instructions = []
for li in self.soup.find("ul", {"class": "recipe_steps"}).findAll("li"):
li.find("span", {"class": "number"}).clear()
instructions.append(li.get_text())
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()