Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,353 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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,46 @@ | ||
# mypy: allow-untyped-defs | ||
|
||
from ._abstract import AbstractScraper | ||
from ._utils import normalize_string | ||
|
||
|
||
class OmnivoresCookbook(AbstractScraper): | ||
@classmethod | ||
def host(cls): | ||
return "omnivorescookbook.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 = self.soup.find( | ||
"ul", {"class": "wprm-recipe-ingredients"} | ||
).find_all("li") | ||
return [normalize_string(ingredient.get_text()) for ingredient in ingredients] | ||
|
||
def instructions(self): | ||
return self.schema.instructions() | ||
|
||
def ratings(self): | ||
return self.schema.ratings() | ||
|
||
def cuisine(self): | ||
return self.schema.cuisine() | ||
|
||
def description(self): | ||
return self.soup.head.find("meta", {"property": "og:description"})["content"] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,66 @@ | ||
# mypy: allow-untyped-defs | ||
|
||
from recipe_scrapers.omnivorescookbook import OmnivoresCookbook | ||
from tests import ScraperTest | ||
|
||
|
||
class TestOmnivoresCookbookScraper(ScraperTest): | ||
|
||
scraper_class = OmnivoresCookbook | ||
|
||
def test_host(self): | ||
self.assertEqual("omnivorescookbook.com", self.harvester_class.host()) | ||
|
||
def test_author(self): | ||
self.assertEqual("Maggie Zhu", self.harvester_class.author()) | ||
|
||
def test_title(self): | ||
self.assertEqual( | ||
"Stir Fried Bok Choy with Tofu Puffs", self.harvester_class.title() | ||
) | ||
|
||
def test_category(self): | ||
self.assertEqual("Side", self.harvester_class.category()) | ||
|
||
def test_total_time(self): | ||
self.assertEqual(15, self.harvester_class.total_time()) | ||
|
||
def test_yields(self): | ||
self.assertEqual("2 servings", self.harvester_class.yields()) | ||
|
||
def test_image(self): | ||
self.assertEqual( | ||
"https://omnivorescookbook.com/wp-content/uploads/2022/02/211213_Stir-Fried-Bok-Choy-With-Tofu-Puffs_550.jpg", | ||
self.harvester_class.image(), | ||
) | ||
|
||
def test_ingredients(self): | ||
self.assertEqual( | ||
[ | ||
"1 lb (450 g) bok choy , chopped to bite size pieces (see the cutting method in the post above)", | ||
"1 heaping cup (60 grams) tofu puffs , halved", | ||
"2 green onions , sliced", | ||
"1 tablespoon peanut oil (or vegetable oil)", | ||
"1 teaspoon sugar", | ||
"2 tablespoons light soy sauce (or soy sauce)", | ||
], | ||
self.harvester_class.ingredients(), | ||
) | ||
|
||
def test_instructions(self): | ||
self.assertEqual( | ||
"Heat 1 tablespoon of oil in a medium-sized wok or large skillet over high heat until hot. Add scallion and stir a few times until fragrant.\nAdd bok choy. Stir and cook for 1 to 2 minutes, to coat evenly with oil.\nSprinkle it with sugar and swirl in light soy sauce. Immediately stir a few times to mix well. Add deep fried tofu, then stir again for about 20 seconds.\nCover the wok and lower to medium-low heat. Steam for 30 seconds. Uncover and stir to check the doneness. Cover and cook for another 10 to 20 seconds again, if necessary, until the bok choy is cooked through and slightly caramelized on the edges. Turn off the heat and transfer everything to a serving plate.\nServe hot as a side dish or over steamed rice as a light main dish.", | ||
self.harvester_class.instructions(), | ||
) | ||
|
||
def test_ratings(self): | ||
self.assertEqual(5.0, self.harvester_class.ratings()) | ||
|
||
def test_cuisine(self): | ||
self.assertEqual("Chinese", self.harvester_class.cuisine()) | ||
|
||
def test_description(self): | ||
self.assertEqual( | ||
"A super quick and easy stir fried bok choy with tofu puffs that only uses five ingredients and takes 15 minutes to prep and cook.", | ||
self.harvester_class.description(), | ||
) |