From 1211a4de605b73421dded148fb4ab0232393c288 Mon Sep 17 00:00:00 2001 From: Sam Balana Date: Sat, 8 Oct 2022 17:55:44 -0700 Subject: [PATCH] Fix ingredients for simplyrecipes.com scraper Update the CSS class for ingredients. While here, also update the formatting of instructions such that colon isn't repeated twice. Refetch the test HTML file for verification. Test: python -m coverage run -m unittest tests.test_simplyrecipes --- recipe_scrapers/simplyrecipes.py | 6 +- tests/test_data/simplyrecipes.testhtml | 3290 +++++++++++++----------- tests/test_simplyrecipes.py | 10 +- 3 files changed, 1826 insertions(+), 1480 deletions(-) diff --git a/recipe_scrapers/simplyrecipes.py b/recipe_scrapers/simplyrecipes.py index 6406033ef..24447fa71 100644 --- a/recipe_scrapers/simplyrecipes.py +++ b/recipe_scrapers/simplyrecipes.py @@ -28,7 +28,9 @@ def yields(self): ) def ingredients(self): - ingredients = self.soup.find("ul", {"class": "ingredient-list"}).findAll("li") + ingredients = self.soup.find( + "ul", {"class": "structured-ingredients__list"} + ).findAll("li") return [normalize_string(ingredient.get_text()) for ingredient in ingredients] @@ -40,7 +42,7 @@ def instructions(self): return "\n".join( [ normalize_string( - step.div.text + ": " + "".join([p.text for p in step.findAll("p")]) + step.div.text + "".join([p.text for p in step.findAll("p")]) ) for step in steps ] diff --git a/tests/test_data/simplyrecipes.testhtml b/tests/test_data/simplyrecipes.testhtml index 5ed1e54ba..0e000b019 100644 --- a/tests/test_data/simplyrecipes.testhtml +++ b/tests/test_data/simplyrecipes.testhtml @@ -1,51 +1,50 @@ - + - + - - - + - + + - + -Homemade Chicken & Rice Soup {One-Pot} +One-Pot Chicken and Rice Soup Recipe - + - + - + - + @@ -55,52 +54,184 @@ - + - + - + - +}); +})(window || {}, Mntl.fnUtilities || {}, Mntl.CMP); - - - - - - - - + + + + + + + + - - - - - + + + + + - + - +
+
+
+
+
+ +
+
+

One-Pot Chicken and Rice Soup

-

One-Pot Chicken and Rice Soup! Throw bone-in chicken, rice, and vegetables together in a pot and simmer until they're done. It's the easiest soup ever, ready in under an hour.

-
-
+
+
-
+ - - + +})(window.Mntl || {});}); +
+ - diff --git a/tests/test_simplyrecipes.py b/tests/test_simplyrecipes.py index 190f8a402..a9921af44 100644 --- a/tests/test_simplyrecipes.py +++ b/tests/test_simplyrecipes.py @@ -30,7 +30,7 @@ def test_ingredients(self): [ "2 bone-in chicken breasts, skin removed (1 to 1 1/2 pounds)", "1 cup long-grain white rice, like basmati", - "2 celery ribs, diced small", + "2 ribs celery, diced small", "2 medium carrots, peeled and diced small", "1 onion, diced small", "2 cloves garlic, peeled but left whole", @@ -47,10 +47,10 @@ def test_instructions(self): return self.assertEqual( "\n".join( [ - "Assemble the soup and bring to a simmer : Combine the chicken, white rice, celery, carrots, onions, garlic, salt, and pepper in a large pot. Add the chicken stock and bring to a boil over high heat. Once the soup is boiling, reduce the heat to keep the soup at a gentle simmer.", - "Simmer for about 25 minutes : As the soup simmers, skim off any foam that collects on the surface with a spoon. Continue to simmer until the rice and vegetables are tender, about 25 minutes. Remove the soup from heat.", - "Shred the chicken and make the garlic paste : Remove the chicken and garlic cloves using a slotted spoon or tongs. Transfer the chicken breasts to a bowl and shred with two forks. Discard the bones. Return the shredded chicken to the pot. Smash the garlic cloves into a paste against a cutting board using a fork or the flat of your knife. Stir the paste back into the soup.", - "Season and serve: : Stir the lemon juice into to the soup, and taste. The soup should taste rich, barely salty, and with just a hint of lemon. Add more salt or lemon juice as needed until it tastes good to you. Divide among bowls and sprinkle with some parsley for serving. Leftovers will keep for about a week refrigerated, or up to 3 months frozen.", + "Assemble the soup and bring to a simmer: Combine the chicken, white rice, celery, carrots, onions, garlic, salt, and pepper in a large pot. Add the chicken stock and bring to a boil over high heat. Once the soup is boiling, reduce the heat to keep the soup at a gentle simmer.", + "Simmer for about 25 minutes: As the soup simmers, skim off any foam that collects on the surface with a spoon. Continue to simmer until the rice and vegetables are tender, about 25 minutes. Remove the soup from heat.", + "Shred the chicken and make the garlic paste: Remove the chicken and garlic cloves using a slotted spoon or tongs. Transfer the chicken breasts to a bowl and shred with two forks. Discard the bones. Return the shredded chicken to the pot. Smash the garlic cloves into a paste against a cutting board using a fork or the flat of your knife. Stir the paste back into the soup.", + "Season and serve: Stir the lemon juice into to the soup, and taste. The soup should taste rich, barely salty, and with just a hint of lemon. Add more salt or lemon juice as needed until it tastes good to you. Divide among bowls and sprinkle with some parsley for serving. Leftovers will keep for about a week refrigerated, or up to 3 months frozen.", ] ), self.harvester_class.instructions(),