Repository: hhursev/recipe-scrapers (language: python)

Issue:
themodernproper: remove duplication of nutritional element names in the nutritional value text
**Pre-filing checks**

- [X] I have searched for open issues that report the same problem
- [X] I have checked that the bug affects the latest version of the library

**The URL of the recipe(s) that are not being scraped correctly**

- https://themodernproper.com/parmesan-crusted-salmon

...

**The results you expect to see**

Found during creation of #1298 the output contains the values name similarly to #1289 .  Will be looking into this shortly!





Discussion / hints:

Fix patch:
diff --git a/recipe_scrapers/themodernproper.py b/recipe_scrapers/themodernproper.py
index f408706cf..bda580a96 100644
--- a/recipe_scrapers/themodernproper.py
+++ b/recipe_scrapers/themodernproper.py
@@ -1,7 +1,35 @@
 from ._abstract import AbstractScraper
+from ._exceptions import ElementNotFoundInHtml
 
 
 class TheModernProper(AbstractScraper):
     @classmethod
     def host(cls):
         return "themodernproper.com"
+
+    def nutrients(self):
+        container = self.schema.nutrients()
+        if not container:
+            raise ElementNotFoundInHtml("Could not find nutritional info container")
+
+        results = {}
+        nutrient_mapping = {
+            "calories": "calories",
+            "fatContent": "fat",
+            "saturatedFatContent": "saturated fat",
+            "carbohydrateContent": "carbohydrates",
+            "sugarContent": "sugar",
+            "proteinContent": "protein",
+            "sodiumContent": "sodium",
+            "fiberContent": "fiber",
+            "cholesterolContent": "cholesterol",
+        }
+
+        for key, value in container.items():
+            if key not in nutrient_mapping:
+                continue
+            redundant_suffix = nutrient_mapping[key]
+            if value.endswith(redundant_suffix):
+                results[key] = value.removesuffix(redundant_suffix).strip()
+
+        return results


Test patch:
diff --git a/tests/test_data/themodernproper.com/themodernproper.json b/tests/test_data/themodernproper.com/themodernproper.json
index 0c4c05273..2464c1b70 100644
--- a/tests/test_data/themodernproper.com/themodernproper.json
+++ b/tests/test_data/themodernproper.com/themodernproper.json
@@ -53,15 +53,15 @@
   "ratings": 5.0,
   "ratings_count": 82,
   "nutrients": {
-    "calories": "463 calories",
-    "fatContent": "35 grams fat",
-    "saturatedFatContent": "15 grams saturated fat",
-    "carbohydrateContent": "11 grams carbohydrates",
-    "sugarContent": "1 grams sugar",
-    "proteinContent": "27 grams protein",
-    "sodiumContent": "1050 milligrams sodium",
-    "fiberContent": "1 grams fiber",
-    "cholesterolContent": "157 milligrams cholesterol"
+    "calories": "463",
+    "fatContent": "35 grams",
+    "saturatedFatContent": "15 grams",
+    "carbohydrateContent": "11 grams",
+    "sugarContent": "1 grams",
+    "proteinContent": "27 grams",
+    "sodiumContent": "1050 milligrams",
+    "fiberContent": "1 grams",
+    "cholesterolContent": "157 milligrams"
   },
   "image": "https://images.themodernproper.com/billowy-turkey/production/posts/2018/swedish-meatballs-13.jpg?w=960&h=540&q=82&fm=jpg&fit=crop&dm=1599768329&s=a12d3adcc54b1d30b5aa25dc6b922e3f",
   "keywords": [