Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions recipe_scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@
from .ricardocuisine import RicardoCuisine
from .ricetta import Ricetta
from .ricetteperbimby import RicettePerBimby
from .rickbayless import RickBayless
from .rosannapansino import RosannaPansino
from .rutgerbakt import RutgerBakt
from .saboresajinomoto import SaboresAjinomoto
Expand Down Expand Up @@ -1118,6 +1119,7 @@
RicardoCuisine.host(): RicardoCuisine,
Ricetta.host(): Ricetta,
RicettePerBimby.host(): RicettePerBimby,
RickBayless.host(): RickBayless,
RosannaPansino.host(): RosannaPansino,
RutgerBakt.host(): RutgerBakt,
SaboresAjinomoto.host(): SaboresAjinomoto,
Expand Down
47 changes: 47 additions & 0 deletions recipe_scrapers/rickbayless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from ._abstract import AbstractScraper
from ._exceptions import StaticValueException, FieldNotProvidedByWebsiteException
from ._utils import get_yields


class RickBayless(AbstractScraper):
@classmethod
def host(cls):
return "rickbayless.com"

def site_name(self):
raise StaticValueException(return_value="Rick Bayless")

def author(self):
raise StaticValueException(return_value="Rick Bayless")

def title(self):
header = self.soup.find("div", {"class": "page-header"})
return header.find("h1").get_text(strip=True)

def total_time(self):
raise FieldNotProvidedByWebsiteException(return_value=None)

def description(self):
desc = self.soup.find("div", {"class": "recipe-description"})
return desc.get_text(strip=True) if desc else None

def ingredients(self):
ingredients_div = self.soup.find("div", {"class": "recipe-ingredients"})
items = ingredients_div.find_all("li", {"itemprop": "ingredients"})
return [" ".join(li.get_text().split()) for li in items]

def instructions(self):
instructions_div = self.soup.find("div", {"class": "recipe-instructions"})
return "\n".join(
p.get_text().strip()
for p in instructions_div.find_all("p")
if p.get_text(strip=True)
)

def yields(self):
servings = self.soup.find("div", {"class": "recipe-servings"})
if not servings:
return None
text = servings.get_text(strip=True)
result = text.replace("Servings:", "").strip()
return get_yields(result)
26 changes: 26 additions & 0 deletions tests/test_data/rickbayless.com/rickbayless.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"author": "Rick Bayless",
"canonical_url": "https://www.rickbayless.com/recipe/mango-guacamole/",
Comment thread
jknndy marked this conversation as resolved.
"site_name": "Rick Bayless",
"host": "rickbayless.com",
"language": "en-US",
"title": "Mango Guacamole",
"ingredients": [
"3 large avocados",
"1/2 small red onion, diced",
"1/2 to 1 fresh serrano chile, seeded and finely chopped",
"2 tablespoons chopped fresh cilantro, plus a few leaves for garnish",
"About 2 tablespoons fresh lime juice",
"1 medium ripe mango, peeled, flesh cut from the pit and diced",
"Salt"
],
"instructions_list": [
"Cut the avocados in half, running your knife around the pit from stem to blossom end and back up again. Twist the halves in opposite directions to free the pit, and pull the halves apart. Dislodge the pit, then scoop the avocado flesh into a large bowl. Coarsely mash the avocado with a large fork or potato masher. Rinse the onion under cold water, shake off the excess water, then add it to the avocado along with the serrano, cilantro and lime juice.",
"Mix in 2/3 of the diced mango. Taste and season with salt. If not using immediately, cover with plastic wrap pressed directly on the surface of the guacamole and refrigerate—preferably for no more than a few hours.",
"When you're ready to serve, scoop the guacamole into a serving bowl and garnish with the remaining diced mango and cilantro sprigs. Serve with tortilla chips, slices of cucumber or jicama."
],
"yields": "2 cups",
"description": "Recipe from Season 6, Mexico—One Plate at a Time",
"total_time": null,
"image": "https://www.rickbayless.com/wp-content/uploads/2013/12/Screen-Shot-2014-04-01-at-12.12.04-PM.png"
Comment thread
jknndy marked this conversation as resolved.
}
Loading
Loading