/
southernliving.py
51 lines (40 loc) · 1.39 KB
/
southernliving.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
51
# mypy: disallow_untyped_defs=False
# southernliving.com scraper
# Written by G.D. Wallters
# Freely released the code to recipe_scraper group
# 9 February, 2020
# =======================================================
from ._abstract import AbstractScraper
from ._utils import get_minutes, get_yields, normalize_string
class SouthernLiving(AbstractScraper):
@classmethod
def host(cls):
return "southernliving.com"
def title(self):
return self.schema.title()
def total_time(self):
return get_minutes(self.schema.total_time())
def yields(self):
return get_yields(self.schema.yields())
def image(self):
return self.schema.image()
def ingredients(self):
return self.schema.ingredients()
def instructions(self):
instructions = self.soup.find("ul", {"class": "instructions-section"}).findAll(
"li", {"class": "instructions-section-item"}
)
return "\n".join(
[
normalize_string(
instruction.find("div", {"class": "paragraph"}).get_text()
)
for instruction in instructions
]
)
def description(self):
des = self.soup.find(
"div",
attrs={"class": lambda e: e.startswith("recipe-summary") if e else False},
)
return normalize_string(des.get_text())