From 2ba46bbb2217fdeb9aff5fb2f1c032de67140a5c Mon Sep 17 00:00:00 2001 From: wengtad Date: Mon, 17 Oct 2022 22:04:22 +0800 Subject: [PATCH 1/2] fix: incomplete justonecookbook --- recipe_scrapers/justonecookbook.py | 25 +- tests/test_data/justonecookbook.testhtml | 1606 ++++++++++++++++++++-- tests/test_justonecookbook.py | 42 +- 3 files changed, 1573 insertions(+), 100 deletions(-) diff --git a/recipe_scrapers/justonecookbook.py b/recipe_scrapers/justonecookbook.py index a1d321740..f5426c51f 100644 --- a/recipe_scrapers/justonecookbook.py +++ b/recipe_scrapers/justonecookbook.py @@ -1,5 +1,7 @@ -# mypy: disallow_untyped_defs=False +# mypy: allow-untyped-defs + from ._abstract import AbstractScraper +from ._utils import normalize_string class JustOneCookbook(AbstractScraper): @@ -7,9 +9,15 @@ class JustOneCookbook(AbstractScraper): def host(cls): return "justonecookbook.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() @@ -20,7 +28,20 @@ def image(self): return self.schema.image() def ingredients(self): - return self.schema.ingredients() + ingredients = self.soup.find_all("li", {"class": "wprm-recipe-ingredient"}) + return [ + normalize_string(ingredient.get_text().replace("▢", "")) + 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.schema.description() diff --git a/tests/test_data/justonecookbook.testhtml b/tests/test_data/justonecookbook.testhtml index 04ecc5ae7..b5df9eae7 100644 --- a/tests/test_data/justonecookbook.testhtml +++ b/tests/test_data/justonecookbook.testhtml @@ -1,133 +1,1571 @@ - Yaki Onigiri (Grilled Rice Ball) 焼きおにぎり • Just One Cookbook + + + + + + + +Yaki Onigiri (Grilled Rice Ball) 焼きおにぎり • Just One Cookbook + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+
+ +
+ +
+
Just One Cookbook Essential Japanese Recipes vol-2

Love Our Recipes?
Check out our cookbooks!

Learn More!
+
+
+ +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Just One Cookbook: Essential Japanese Recipes

Love Our Recipes?
Checkout our Ebook!

Purchase Today!
Gyoza served on a plate.
Just One Cookbook logo

free email series

5 Secrets to Japanese Cooking

Making flavorful Japanese food is

EASIER than you think.

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

No thanks, I am not interested
JOC Logo 2021
Close
+document.addEventListener('scroll',function(){if(window.scrollY>12)lazySrc()}) + + diff --git a/tests/test_justonecookbook.py b/tests/test_justonecookbook.py index ab03e722b..0240cd686 100644 --- a/tests/test_justonecookbook.py +++ b/tests/test_justonecookbook.py @@ -1,31 +1,33 @@ +# mypy: allow-untyped-defs + from recipe_scrapers.justonecookbook import JustOneCookbook from tests import ScraperTest -class TestJustOneCookbook(ScraperTest): +class TestJustOneCookbookScraper(ScraperTest): scraper_class = JustOneCookbook def test_host(self): self.assertEqual("justonecookbook.com", self.harvester_class.host()) - def test_canonical_url(self): - self.assertEqual( - "https://www.justonecookbook.com/yaki-onigiri-grilled-rice-ball/", - self.harvester_class.canonical_url(), - ) + def test_author(self): + self.assertEqual("Namiko Chen", self.harvester_class.author()) def test_title(self): self.assertEqual( - self.harvester_class.title(), "Yaki Onigiri (Grilled Rice Ball)" + "Yaki Onigiri (Grilled Rice Ball)", self.harvester_class.title() ) - def test_yields(self): - self.assertEqual("6 servings", self.harvester_class.yields()) + def test_category(self): + self.assertEqual("Side Dish", self.harvester_class.category()) def test_total_time(self): self.assertEqual(30, self.harvester_class.total_time()) + def test_yields(self): + self.assertEqual("6 servings", self.harvester_class.yields()) + def test_image(self): self.assertEqual( "https://www.justonecookbook.com/wp-content/uploads/2020/03/Yaki-Onigiri-Grilled-Rice-Ball-9532-I.jpg", @@ -35,17 +37,29 @@ def test_image(self): def test_ingredients(self): self.assertEqual( [ - "2 rice cooker cups uncooked Japanese short-grain rice", + "2 rice cooker cups uncooked Japanese short-grain rice (2 rice-cooker-cups (180 ml x 2 = 360 ml) yields roughly 4 servings (3 ½ US cups) or 6 rice balls; see how to cook short-grain rice with a rice cooker, a pot over the stove, an instant pot, or a donabe)", "400 ml water", - "1 Tbsp kosher/sea salt (I use Diamond Crystal; use half for table salt) ((you do not need to use all of it))", - "1 Tbsp neutral-flavored oil (vegetable, rice bran, canola, etc)", - "soy sauce ((I love using my homemade unagi sauce))", + "1 Tbsp kosher salt (Diamond Crystal; use half for table salt) (you do not need to use all of it)", + "1 Tbsp neutral-flavored oil (vegetable, rice bran, canola, etc.)", + "soy sauce (I love using my homemade unagi sauce)", ], self.harvester_class.ingredients(), ) def test_instructions(self): - return self.assertEqual( + self.assertEqual( "Gather all the ingredients. Cook the rice with a rice cooker, a pot over the stove, an instant pot, or a donabe. Let the cooked rice cool a little bit until you can hold rice without burning your hands. Do not let the rice completely cool down.\nTo Make Rice Balls\nFirst, wet both of your hands with water so the rice won’t stick.\nThen put some salt in your hands and rub to spread all around.\nScoop about a half cup of rice onto your palm.\nCover the rice with the other hand and gently form the rice into a triangle.\nMake sure the covering hand (my right hand) should be forming a triangle shape. When forming the onigiri shape, your hands should be just firm enough so the onigiri doesn't fall apart. You don't want to squeeze the rice too tight.\nI use three fingers (thumb, index finger, middle finger) to cover the area to make a nice triangle shape. Then rotate onigiri to make a perfect triangle.\nWhile you squeeze onigiri firmly with both hands, one of your hands has to press onigiri to keep a nice form.\nGently squeeze the center of the triangle on both sides so there is a slight indentation (for grilling onigiri). Now onigiri is ready! You can tell I’m not a good onigiri maker – no matter how many years I have been practicing.\nTo Grill Rice Ball\nLightly oil a cast-iron skillet and put it on medium heat.\nGrill onigiri until all sides are crispy and lightly browned. Rice will release itself when it forms a nice crust. Don’t flip it quickly. Just work on one side at a time and avoid turning over frequently, which may end up breaking into pieces.\nOnce all nicely toasted and lightly brown, lower heat to medium-low heat. Brush all sides with soy sauce (or unagi sauce). Rotate to make sure all sides become crispy. Be careful not to burn onigiri after you brush it with the sauce.\nTo Store\nRice gets hard when you refrigerate. You can individually wrap the Yaki Onigiri in plastic wrap and cover them with a thick kitchen towel and store in the refrigerator for up to 2 days. The towel will prevent the rice from getting too cold and keep the food stay cool but not cold. When you're ready to eat, bring it back to room temperature and reheat in a microwave or frying pan.", self.harvester_class.instructions(), ) + + def test_ratings(self): + self.assertEqual(4.66, self.harvester_class.ratings()) + + def test_cuisine(self): + self.assertEqual("Japanese", self.harvester_class.cuisine()) + + def test_description(self): + self.assertEqual( + "A favorite at Izakaya restaurants, Yaki Onigiri are Japanese grilled rice balls covered in savory soy sauce. With a crispy crust on the outside and soft sticky rice on the inside, these rice balls are simply irresistible and easy to make at home!", + self.harvester_class.description(), + ) From bf96bdd1a163c5abc823560a4adafb24c7d29cde Mon Sep 17 00:00:00 2001 From: wengtad Date: Wed, 19 Oct 2022 20:50:35 +0800 Subject: [PATCH 2/2] fix: remove replace --- recipe_scrapers/justonecookbook.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/recipe_scrapers/justonecookbook.py b/recipe_scrapers/justonecookbook.py index f5426c51f..a56604d13 100644 --- a/recipe_scrapers/justonecookbook.py +++ b/recipe_scrapers/justonecookbook.py @@ -28,11 +28,17 @@ def image(self): return self.schema.image() def ingredients(self): - ingredients = self.soup.find_all("li", {"class": "wprm-recipe-ingredient"}) - return [ - normalize_string(ingredient.get_text().replace("▢", "")) - for ingredient in ingredients - ] + lis = self.soup.find_all("li", {"class": "wprm-recipe-ingredient"}) + ingredients = [] + for ingredient in lis: + spans = ingredient.findAll( + "span", class_=lambda x: x != "wprm-checkbox-container" + )[1:] + ingredient = [] + for span in spans: + ingredient.append(normalize_string(span.get_text())) + ingredients.append(" ".join(ingredient)) + return ingredients def instructions(self): return self.schema.instructions()