-
Notifications
You must be signed in to change notification settings - Fork 645
Add scraper for rickbayless.com #1889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||||||||||||
| from ._abstract import AbstractScraper | ||||||||||||||||||
| from ._exceptions import StaticValueException | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class RickBayless(AbstractScraper): | ||||||||||||||||||
| @classmethod | ||||||||||||||||||
| def host(cls): | ||||||||||||||||||
| return "rickbayless.com" | ||||||||||||||||||
|
|
||||||||||||||||||
| def site_name(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 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 image(self): | ||||||||||||||||||
| og_image = self.soup.find("meta", {"property": "og:image"}) | ||||||||||||||||||
| return og_image["content"] if og_image else None | ||||||||||||||||||
|
|
||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The built in |
||||||||||||||||||
| 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 result or None | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||
| { | ||||||||
| "canonical_url": "https://www.rickbayless.com/recipe/mango-guacamole/", | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| "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 1/2 cups", | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| "description": "Recipe from Season 6, Mexico—One Plate at a Time", | ||||||||
| "image": "https://www.rickbayless.com/wp-content/uploads/2013/12/Screen-Shot-2014-04-01-at-12.12.04-PM.png" | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.