From 9af789cc12a6461f73b5332439f95f2c9346a265 Mon Sep 17 00:00:00 2001 From: Noah Hernandez <63211322+oahnh@users.noreply.github.com> Date: Sun, 20 Oct 2024 18:53:03 -0700 Subject: [PATCH 1/2] fix(maangchi.com): use regex string to find ingredients header --- recipe_scrapers/maangchi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipe_scrapers/maangchi.py b/recipe_scrapers/maangchi.py index 3656ed1d7..85312accd 100644 --- a/recipe_scrapers/maangchi.py +++ b/recipe_scrapers/maangchi.py @@ -1,3 +1,5 @@ +import re + from ._abstract import AbstractScraper from ._utils import normalize_string @@ -8,7 +10,9 @@ def host(cls): return "maangchi.com" def ingredients(self): - before = self.soup.find("h2", string="Ingredients").find_all_next("li") + before = self.soup.find( + "h2", string=re.compile(r"Ingredients(\s*\(.*\))?") + ).find_all_next("li") after = self.soup.find("h2", string="Directions").find_all_previous("li") list_before = [normalize_string(b.get_text()) for b in before] list_after = [normalize_string(a.get_text()) for a in after] From 69be432fa9ddd8f487c4c35f0675364fc0674b84 Mon Sep 17 00:00:00 2001 From: Noah Hernandez <63211322+oahnh@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:33:36 -0700 Subject: [PATCH 2/2] chore: formatting --- recipe_scrapers/maangchi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipe_scrapers/maangchi.py b/recipe_scrapers/maangchi.py index 85312accd..57b557765 100644 --- a/recipe_scrapers/maangchi.py +++ b/recipe_scrapers/maangchi.py @@ -10,9 +10,9 @@ def host(cls): return "maangchi.com" def ingredients(self): - before = self.soup.find( - "h2", string=re.compile(r"Ingredients(\s*\(.*\))?") - ).find_all_next("li") + before = self.soup.find("h2", string=re.compile(r"Ingredients")).find_all_next( + "li" + ) after = self.soup.find("h2", string="Directions").find_all_previous("li") list_before = [normalize_string(b.get_text()) for b in before] list_after = [normalize_string(a.get_text()) for a in after]