From 5059a15826a18ce0a4041e10164ef6b9eb39db64 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 11 Jul 2023 00:17:24 +0200 Subject: [PATCH] menu and submenu --- lib/WPMenu.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/WPMenu.py b/lib/WPMenu.py index 64bbb71..c87e585 100644 --- a/lib/WPMenu.py +++ b/lib/WPMenu.py @@ -56,6 +56,7 @@ class WPMenu: ## Get from URL def fromUrl(self, canalblog): + self._canalblog = canalblog try: o = urlparse(canalblog) o = o._replace(scheme=self._protocol_canalblog) @@ -105,11 +106,12 @@ class WPMenu: for anchor in ul.find_all("li"): parent = anchor.find("a").get_text().replace(" \xa0", "") + href = anchor.find("a").get("href") + if href == "{0}://{1}/".format(self._protocol_canalblog, self._canalblog): + parent = "home" itemMenu = {"id":"", "type":"", "title": parent, "children":list()} - href = anchor.find("a").get("href") - if href == self._wordpress: - parent = "home" + #menu = self._child(parent, parent) if href == "#": li = anchor.find("ul").find_all("li") @@ -131,4 +133,4 @@ class WPMenu: menu[j]["children"].append({"id":"", "title":children[i]["title"], "parent": children[i]["parent"]}) for i in menu: - self._logger.info("{0} : Menu {1}".format(self._name)) \ No newline at end of file + self._logger.info("{0} : Menu {1} {2}".format(self._name, i["title"], len(i["children"]))) \ No newline at end of file