From f6de07eefcc95a90f3ec0c215427c699e258dc0f Mon Sep 17 00:00:00 2001 From: Joey <7505194+jknndy@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:34:55 -0400 Subject: [PATCH 1/7] implement sudobash1's recommended fix --- recipe_scrapers/americastestkitchen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipe_scrapers/americastestkitchen.py b/recipe_scrapers/americastestkitchen.py index 589b9c952..08fdc68f9 100644 --- a/recipe_scrapers/americastestkitchen.py +++ b/recipe_scrapers/americastestkitchen.py @@ -71,5 +71,4 @@ def _parse_ingredient_item(ingredient_item): @functools.cached_property def _get_additional_details(self): j = json.loads(self.soup.find(type="application/json").string) - name = list(j["props"]["initialState"]["content"]["documents"])[0] - return j["props"]["initialState"]["content"]["documents"][name] + return j["props"]["pageProps"]["data"] From 7466962ed2d5291d8862547679290f771fd0efec Mon Sep 17 00:00:00 2001 From: Joey <7505194+jknndy@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:39:29 -0400 Subject: [PATCH 2/7] updated test data --- .../americastestkitchen.json | 31 +- .../americastestkitchen.testhtml | 6663 +++++++++-------- 2 files changed, 3422 insertions(+), 3272 deletions(-) diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen.json b/tests/test_data/americastestkitchen.com/americastestkitchen.json index fd113faaf..ee74b3170 100644 --- a/tests/test_data/americastestkitchen.com/americastestkitchen.json +++ b/tests/test_data/americastestkitchen.com/americastestkitchen.json @@ -72,13 +72,36 @@ ], "category": "Main Courses, Casseroles", "yields": "8 servings", - "description": "Could we adapt and simplify this northern Italian classic for the American kitchen?", + "description": "Could we adapt and simplify this northern Italian classic for the American kitchen? When we started thinking about a simple lasagna Bolognese recipe, there was no denying the appeal of no-boil noodles. After several tests, we found that a five-minute soak proved most effective for getting sturdy, al dente noodles that bound together the layers of ragu and béchamel without soaking up all the moisture. Stumbling through multiple rounds of meat sauce testing gave us the idea of combining the ragu and béchamel when both were lukewarm. The resulting sauce was thickened but easy to spread, with enough moisture for cooking the noodles in our simplified lasagna recipe.", "total_time": 210, "cuisine": "Europe, Italian", "ratings": 4.4, - "ratings_count": 80, + "ratings_count": 98, "nutrients": { - "calories": "5764 calories" + "calories": "721", + "fatContent": "40 grams", + "saturatedFatContent": "20 grams", + "unsaturatedFatContent": "14 grams", + "transFatContent": "1 grams", + "carbohydrateContent": "39 grams", + "sugarContent": "13 grams", + "proteinContent": "39 grams", + "sodiumContent": "1165 miligrams", + "cholesterolContent": "119 miligrams" }, - "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/3801_so04-lasagnabolognes-article" + "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/3801_so04-lasagnabolognes-article", + "keywords": [ + "Main Courses", + "Europe", + "Italian", + "Pasta", + "Grains", + "Rice & Beans", + "Eggs & Dairy", + "Meat", + "Cheese", + "Beef", + "Pork", + "Casseroles" + ] } diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen.testhtml b/tests/test_data/americastestkitchen.com/americastestkitchen.testhtml index f698920be..28aae8941 100644 --- a/tests/test_data/americastestkitchen.com/americastestkitchen.testhtml +++ b/tests/test_data/americastestkitchen.com/americastestkitchen.testhtml @@ -15,3203 +15,44 @@ j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl ; f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','GTM-MFMR9K');America's Test Kitchen LogoCook's Country LogoCook's Illustrated Logo \ No newline at end of file From 11a8f4a31f8aafdc01882c8a042079ba6a5cd145 Mon Sep 17 00:00:00 2001 From: Joey <7505194+jknndy@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:55:47 -0400 Subject: [PATCH 3/7] cookscountry --- .../cookscountry.com/cookscountry.json | 2 +- .../cookscountry.com/cookscountry.testhtml | 6665 +++++++++-------- 2 files changed, 3396 insertions(+), 3271 deletions(-) diff --git a/tests/test_data/cookscountry.com/cookscountry.json b/tests/test_data/cookscountry.com/cookscountry.json index 34ed1b6b2..10e857bf0 100644 --- a/tests/test_data/cookscountry.com/cookscountry.json +++ b/tests/test_data/cookscountry.com/cookscountry.json @@ -73,7 +73,7 @@ "total_time": 75, "cuisine": "Latin America & Caribbean, Mexican", "ratings": 4.2, - "ratings_count": 39, + "ratings_count": 56, "nutrients": { "calories": "687", "fatContent": "31 grams", diff --git a/tests/test_data/cookscountry.com/cookscountry.testhtml b/tests/test_data/cookscountry.com/cookscountry.testhtml index be399ece8..d1f084652 100644 --- a/tests/test_data/cookscountry.com/cookscountry.testhtml +++ b/tests/test_data/cookscountry.com/cookscountry.testhtml @@ -15,3203 +15,44 @@ j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl ; f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','GTM-MFMR9K');America's Test Kitchen LogoCook's Country LogoCook's Illustrated Logo \ No newline at end of file From 61f0b7963a1c600fc6d64afbbfab955c984f95de Mon Sep 17 00:00:00 2001 From: Joey <7505194+jknndy@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:55:58 -0400 Subject: [PATCH 4/7] cooksillustrated --- .../cooksillustrated.json | 4 +- .../cooksillustrated.testhtml | 6662 +++++++++-------- 2 files changed, 3394 insertions(+), 3272 deletions(-) diff --git a/tests/test_data/cooksillustrated.com/cooksillustrated.json b/tests/test_data/cooksillustrated.com/cooksillustrated.json index 582c6db67..aeb86b2c8 100644 --- a/tests/test_data/cooksillustrated.com/cooksillustrated.json +++ b/tests/test_data/cooksillustrated.com/cooksillustrated.json @@ -21,8 +21,8 @@ "description": "Whisk butter into a little simmering water and—poof!—you've got beurre monté: liquid silk that pairs with any seasoning and gilds everything it touches. Beurre monté, emulsified melted butter, is a classic French preparation that can be drizzled over cooked meats, vegetables, pastas, and other dishes to add richness and a glossy appearance or used as a rich, creamy sauce base for pairing with a wide range of savory or sweet seasonings. Vigorously whisking cold butter into a measured amount of simmering water broke up the butterfat into tiny droplets that dispersed throughout the water, establishing a thick, creamy emulsion. Whisking oyster sauce plus orange zest and juice into the beurre monté produced a bold, rich, easy-to-make sauce that paired especially well with lean roasted or pan-seared proteins such as scallops, cod, pork tenderloin, or chicken breast; it was also great over pasta.", "total_time": 10, "cuisine": "French", - "ratings": 4.5, - "ratings_count": 26, + "ratings": 4.2, + "ratings_count": 44, "nutrients": { "calories": "207", "fatContent": "23 grams", diff --git a/tests/test_data/cooksillustrated.com/cooksillustrated.testhtml b/tests/test_data/cooksillustrated.com/cooksillustrated.testhtml index 0f6a57b99..83dd8e5b5 100644 --- a/tests/test_data/cooksillustrated.com/cooksillustrated.testhtml +++ b/tests/test_data/cooksillustrated.com/cooksillustrated.testhtml @@ -15,3203 +15,44 @@ j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl ; f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','GTM-MFMR9K');America's Test Kitchen LogoCook's Country LogoCook's Illustrated Logo \ No newline at end of file From bee40c74d00c1eb5b28a2a3e70588477d51e3c8f Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 3 Nov 2024 14:35:23 -0500 Subject: [PATCH 5/7] rename --- .../{americastestkitchen.json => americastestkitchen_1.json} | 0 ...mericastestkitchen.testhtml => americastestkitchen_1.testhtml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/test_data/americastestkitchen.com/{americastestkitchen.json => americastestkitchen_1.json} (100%) rename tests/test_data/americastestkitchen.com/{americastestkitchen.testhtml => americastestkitchen_1.testhtml} (100%) diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen.json b/tests/test_data/americastestkitchen.com/americastestkitchen_1.json similarity index 100% rename from tests/test_data/americastestkitchen.com/americastestkitchen.json rename to tests/test_data/americastestkitchen.com/americastestkitchen_1.json diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen.testhtml b/tests/test_data/americastestkitchen.com/americastestkitchen_1.testhtml similarity index 100% rename from tests/test_data/americastestkitchen.com/americastestkitchen.testhtml rename to tests/test_data/americastestkitchen.com/americastestkitchen_1.testhtml From f9060fd1915b588c7b53ecce63cc66bb8db1f69c Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 3 Nov 2024 14:35:36 -0500 Subject: [PATCH 6/7] Test case for old format --- .../americastestkitchen_2.json | 107 + .../americastestkitchen_2.testhtml | 3832 +++++++++++++++++ 2 files changed, 3939 insertions(+) create mode 100644 tests/test_data/americastestkitchen.com/americastestkitchen_2.json create mode 100644 tests/test_data/americastestkitchen.com/americastestkitchen_2.testhtml diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen_2.json b/tests/test_data/americastestkitchen.com/americastestkitchen_2.json new file mode 100644 index 000000000..ee74b3170 --- /dev/null +++ b/tests/test_data/americastestkitchen.com/americastestkitchen_2.json @@ -0,0 +1,107 @@ +{ + "author": "America's Test Kitchen", + "canonical_url": "https://www.americastestkitchen.com/recipes/1629-lasagna-bolognese-simplified", + "site_name": "America's Test Kitchen", + "host": "americastestkitchen.com", + "language": "en", + "title": "Lasagna Bolognese, Simplified", + "ingredients": [ + "1 medium carrot, peeled and roughly chopped", + "1 medium rib celery, roughly chopped", + "1/2 small onion, roughly chopped", + "1 (28 ounce) can whole tomatoes with juice", + "2 tablespoons unsalted butter", + "8 ounces ground beef, preferably 90 percent lean", + "8 ounces ground pork", + "8 ounces ground veal", + "1 1/2 cups whole milk", + "1 1/2 cups dry white wine", + "2 tablespoons tomato paste", + "1 teaspoon table salt", + "1/4 teaspoon ground black pepper", + "4 tablespoons unsalted butter", + "1/4 cup unbleached all-purpose flour", + "4 cups whole milk", + "3/4 teaspoon table salt", + "15 sheets no-boil lasagna noodle (9 ounces)", + "4 ounces Parmesan cheese, grated (2 cups)" + ], + "ingredient_groups": [ + { + "ingredients": [ + "1 medium carrot, peeled and roughly chopped", + "1 medium rib celery, roughly chopped", + "1/2 small onion, roughly chopped", + "1 (28 ounce) can whole tomatoes with juice", + "2 tablespoons unsalted butter", + "8 ounces ground beef, preferably 90 percent lean", + "8 ounces ground pork", + "8 ounces ground veal", + "1 1/2 cups whole milk", + "1 1/2 cups dry white wine", + "2 tablespoons tomato paste", + "1 teaspoon table salt", + "1/4 teaspoon ground black pepper" + ], + "purpose": "Meat Sauce (Ragù)" + }, + { + "ingredients": [ + "4 tablespoons unsalted butter", + "1/4 cup unbleached all-purpose flour", + "4 cups whole milk", + "3/4 teaspoon table salt" + ], + "purpose": "Béchamel" + }, + { + "ingredients": [ + "15 sheets no-boil lasagna noodle (9 ounces)", + "4 ounces Parmesan cheese, grated (2 cups)" + ], + "purpose": "Noodles and Cheese" + } + ], + "instructions_list": [ + "Note: For assembly, both the meat sauce and the bechamel should be just warm to the touch, not piping hot. Both sauces can be made, cooled, and refrigerated up to 2 days ahead, then gently reheated until warm. In terms of flavor and texture, we find that Barilla no-boil noodles are the closest to fresh, but this recipe will work with all major brands of no-boil noodles.", + "For the meat sauce: Process carrot, celery, and onion in food processor until finely chopped, about ten 1-second pulses, scraping down bowl as necessary; transfer mixture to small bowl. Wipe out food processor workbowl; process tomatoes and juice until finely chopped, six to eight 1-second pulses. Heat butter in heavy-bottomed Dutch oven over medium heat until foaming; add carrot, celery, and onion and cook, stirring occasionally, until softened but not browned, about 4 minutes. Add ground meats and cook, breaking meat into 1-inch pieces with wooden spoon, about 1 minute. Add milk and stir, breaking meat into 1/2-inch bits; bring to simmer and cook, stirring to break meat into small pieces, until almost all liquid has evaporated, 20 to 30 minutes. Using potato masher or wooden spoon, break up any remaining clumps of meat (no large pieces should remain). Add wine and bring to simmer; cook, stirring occasionally, until liquid has evaporated, 20 to 30 minutes. Stir in tomato paste until combined, about 1 minute; add chopped tomatoes, salt, and pepper. Bring to simmer, then reduce heat to medium-low and cook until sauce is slightly thickened, about 15 minutes. (You should have about 6 cups meat sauce.) Transfer meat sauce to bowl and cool until just warm to touch, about 30 minutes.", + "For the béchamel: While meat sauce simmers, melt butter in medium saucepan over medium heat until foaming; add flour and cook, whisking constantly, until thoroughly combined, about 1 1/2 minutes; mixture should not brown. Gradually whisk in milk; increase heat to medium-high and bring to full boil, whisking frequently. Add salt, reduce heat to medium-low, and simmer 10 minutes, stirring occasionally with heatproof rubber spatula or wooden spoon, making sure to scrape bottom and corners of saucepan. (You should have about 3 1/3 cups.) Transfer béchamel to bowl and cool until just warm to touch, about 30 minutes.", + "To assemble and bake: Adjust oven rack to middle position; heat oven to 425 degrees. Place noodles in 13- by 9-inch baking dish and cover with very hot tap water; soak 5 minutes, agitating noodles occasionally to prevent sticking. Remove noodles from water, place in single layer on kitchen towel, and pat dry. Wipe out baking dish and spray lightly with nonstick cooking spray. Stir béchamel to recombine; mix 3/4 cup warm béchamel into warm meat sauce until thoroughly combined.", + "Distribute 1 cup béchamel-enriched meat sauce in baking dish. Place three noodles in single layer on top of sauce, arranging them close together, but not touching, at center of pan. Spread 1 1/4 cups béchamel-enriched meat sauce evenly over noodles, spreading sauce to edge of noodles but not to edge of dish (see illustration 1). Drizzle 1/3 cup béchamel evenly over meat sauce (illustration 2). Sprinkle 1/3 cup Parmesan evenly over béchamel. Repeat layering of noodles, béchamel-enriched meat sauce, bechamel, and cheese 3 more times. Place final 3 noodles on top and cover completely with remaining béchamel, spreading béchamel with rubber spatula and allowing it to spill over noodles (illustration 3). Sprinkle evenly with remaining Parmesan.", + "Spray large sheet foil with nonstick cooking spray and cover lasagna; bake until bubbling, about 30 minutes. Remove foil, increase heat to 450 degrees, and continue to bake until surface is spotty brown, about 15 minutes. Cool 15 minutes; cut into pieces and serve." + ], + "category": "Main Courses, Casseroles", + "yields": "8 servings", + "description": "Could we adapt and simplify this northern Italian classic for the American kitchen? When we started thinking about a simple lasagna Bolognese recipe, there was no denying the appeal of no-boil noodles. After several tests, we found that a five-minute soak proved most effective for getting sturdy, al dente noodles that bound together the layers of ragu and béchamel without soaking up all the moisture. Stumbling through multiple rounds of meat sauce testing gave us the idea of combining the ragu and béchamel when both were lukewarm. The resulting sauce was thickened but easy to spread, with enough moisture for cooking the noodles in our simplified lasagna recipe.", + "total_time": 210, + "cuisine": "Europe, Italian", + "ratings": 4.4, + "ratings_count": 98, + "nutrients": { + "calories": "721", + "fatContent": "40 grams", + "saturatedFatContent": "20 grams", + "unsaturatedFatContent": "14 grams", + "transFatContent": "1 grams", + "carbohydrateContent": "39 grams", + "sugarContent": "13 grams", + "proteinContent": "39 grams", + "sodiumContent": "1165 miligrams", + "cholesterolContent": "119 miligrams" + }, + "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/3801_so04-lasagnabolognes-article", + "keywords": [ + "Main Courses", + "Europe", + "Italian", + "Pasta", + "Grains", + "Rice & Beans", + "Eggs & Dairy", + "Meat", + "Cheese", + "Beef", + "Pork", + "Casseroles" + ] +} diff --git a/tests/test_data/americastestkitchen.com/americastestkitchen_2.testhtml b/tests/test_data/americastestkitchen.com/americastestkitchen_2.testhtml new file mode 100644 index 000000000..28aae8941 --- /dev/null +++ b/tests/test_data/americastestkitchen.com/americastestkitchen_2.testhtml @@ -0,0 +1,3832 @@ + +Lasagna Bolognese, Simplified | America's Test Kitchen Recipe
America's Test Kitchen LogoCook's Country LogoCook's Illustrated Logo

Lasagna Bolognese, Simplified

Could we adapt and simplify this northern Italian classic for the American kitchen?

SERVES 8

TIME 3 hours, plus 30 minutes cooling

Lasagna Bolognese, Simplified

Why This Recipe Works

Gather Your Ingredients

Meat Sauce (Ragù)
Béchamel
Noodles and Cheese

Key Equipment

Key Equipment - Food Processors
Key Equipment - Dutch Ovens
Key Equipment - All-Purpose Whisks

Before You Begin

*

For assembly, both the meat sauce and the bechamel should be just warm to the touch, not piping hot. Both sauces can be made, cooled, and refrigerated up to 2 days ahead, then gently reheated until warm. In terms of flavor and texture, we find that Barilla no-boil noodles are the closest to fresh, but this recipe will work with all major brands of no-boil noodles.

+

Instructions

1.

For the meat sauce: Process carrot, celery, and onion in food processor until finely chopped, about ten 1-second pulses, scraping down bowl as necessary; transfer mixture to small bowl. Wipe out food processor workbowl; process tomatoes and juice until finely chopped, six to eight 1-second pulses. Heat butter in heavy-bottomed Dutch oven over medium heat until foaming; add carrot, celery, and onion and cook, stirring occasionally, until softened but not browned, about 4 minutes. Add ground meats and cook, breaking meat into 1-inch pieces with wooden spoon, about 1 minute. Add milk and stir, breaking meat into 1/2-inch bits; bring to simmer and cook, stirring to break meat into small pieces, until almost all liquid has evaporated, 20 to 30 minutes. Using potato masher or wooden spoon, break up any remaining clumps of meat (no large pieces should remain). Add wine and bring to simmer; cook, stirring occasionally, until liquid has evaporated, 20 to 30 minutes. Stir in tomato paste until combined, about 1 minute; add chopped tomatoes, salt, and pepper. Bring to simmer, then reduce heat to medium-low and cook until sauce is slightly thickened, about 15 minutes. (You should have about 6 cups meat sauce.) Transfer meat sauce to bowl and cool until just warm to touch, about 30 minutes.

+

2.

For the béchamel: While meat sauce simmers, melt butter in medium saucepan over medium heat until foaming; add flour and cook, whisking constantly, until thoroughly combined, about 1 1/2 minutes; mixture should not brown. Gradually whisk in milk; increase heat to medium-high and bring to full boil, whisking frequently. Add salt, reduce heat to medium-low, and simmer 10 minutes, stirring occasionally with heatproof rubber spatula or wooden spoon, making sure to scrape bottom and corners of saucepan. (You should have about 3 1/3 cups.) Transfer béchamel to bowl and cool until just warm to touch, about 30 minutes.

+

3.

To assemble and bake: Adjust oven rack to middle position; heat oven to 425 degrees. Place noodles in 13- by 9-inch baking dish and cover with very hot tap water; soak 5 minutes, agitating noodles occasionally to prevent sticking. Remove noodles from water, place in single layer on kitchen towel, and pat dry. Wipe out baking dish and spray lightly with nonstick cooking spray. Stir béchamel to recombine; mix 3/4 cup warm béchamel into warm meat sauce until thoroughly combined.

+

4.

Distribute 1 cup béchamel-enriched meat sauce in baking dish. Place three noodles in single layer on top of sauce, arranging them close together, but not touching, at center of pan. Spread 1 1/4 cups béchamel-enriched meat sauce evenly over noodles, spreading sauce to edge of noodles but not to edge of dish (see illustration 1). Drizzle 1/3 cup béchamel evenly over meat sauce (illustration 2). Sprinkle 1/3 cup Parmesan evenly over béchamel. Repeat layering of noodles, béchamel-enriched meat sauce, bechamel, and cheese 3 more times. Place final 3 noodles on top and cover completely with remaining béchamel, spreading béchamel with rubber spatula and allowing it to spill over noodles (illustration 3). Sprinkle evenly with remaining Parmesan.

+

5.

Spray large sheet foil with nonstick cooking spray and cover lasagna; bake until bubbling, about 30 minutes. Remove foil, increase heat to 450 degrees, and continue to bake until surface is spotty brown, about 15 minutes. Cool 15 minutes; cut into pieces and serve.

+

Test Kitchen Techniques

FROM OUR TV SPONSORS

We are thankful to the sponsors who make it possible for us to bring you the America's Test Kitchen TV series on public television. Read more about why we have sponsors.

This is a members' feature.

America's Test Kitchen LogoCook's Country LogoCook's Illustrated Logo \ No newline at end of file From 76415abd686319ff29a53dbfc78cdd8437e3d9eb Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 3 Nov 2024 14:35:51 -0500 Subject: [PATCH 7/7] Add fallback for old format w/ comments --- recipe_scrapers/americastestkitchen.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recipe_scrapers/americastestkitchen.py b/recipe_scrapers/americastestkitchen.py index 08fdc68f9..a2ec71852 100644 --- a/recipe_scrapers/americastestkitchen.py +++ b/recipe_scrapers/americastestkitchen.py @@ -71,4 +71,10 @@ def _parse_ingredient_item(ingredient_item): @functools.cached_property def _get_additional_details(self): j = json.loads(self.soup.find(type="application/json").string) - return j["props"]["pageProps"]["data"] + # Handling for new page format + if "pageProps" in j["props"]: + return j["props"]["pageProps"]["data"] + else: + # Handling for old page format + name = list(j["props"]["initialState"]["content"]["documents"])[0] + return j["props"]["initialState"]["content"]["documents"][name]