Skip to content
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

Fix additional details extraction in ATK scraper #1320

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions recipe_scrapers/americastestkitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
31 changes: 27 additions & 4 deletions tests/test_data/americastestkitchen.com/americastestkitchen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
jknndy marked this conversation as resolved.
Show resolved Hide resolved
"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"
]
}
6,663 changes: 3,395 additions & 3,268 deletions tests/test_data/americastestkitchen.com/americastestkitchen.testhtml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_data/cookscountry.com/cookscountry.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6,665 changes: 3,395 additions & 3,270 deletions tests/test_data/cookscountry.com/cookscountry.testhtml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/test_data/cooksillustrated.com/cooksillustrated.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading