-
Notifications
You must be signed in to change notification settings - Fork 664
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/", | ||
| "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" | ||
|
jknndy marked this conversation as resolved.
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.