list menu wip
This commit is contained in:
parent
03f833a2c3
commit
74fa87ea73
@ -73,7 +73,7 @@ class WPMenu:
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err))
|
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err))
|
||||||
|
|
||||||
def _child(self, title, parent):
|
def _getId(self, title, parent):
|
||||||
menu = {"id":"", "type":"", "title": "", "parent":"", "children": []}
|
menu = {"id":"", "type":"", "title": "", "parent":"", "children": []}
|
||||||
exist = False
|
exist = False
|
||||||
for i in ["categories", "tags"]:
|
for i in ["categories", "tags"]:
|
||||||
@ -100,31 +100,31 @@ class WPMenu:
|
|||||||
|
|
||||||
soup = BeautifulSoup(content, self._parser)
|
soup = BeautifulSoup(content, self._parser)
|
||||||
ul = soup.find("ul", id="listsmooth")
|
ul = soup.find("ul", id="listsmooth")
|
||||||
menus = list()
|
menu = list()
|
||||||
menu = {"id":"", "type":"", "title": "", "parent":"", "children": []}
|
|
||||||
parents = list()
|
parents = list()
|
||||||
children = list()
|
|
||||||
for anchor in ul.find_all("li"):
|
for anchor in ul.find_all("li"):
|
||||||
parent = anchor.find("a").get_text()
|
|
||||||
|
parent = anchor.find("a").get_text().replace(" \xa0", "")
|
||||||
|
itemMenu = {"id":"", "type":"", "title": parent, "parent": parent, "children":[]}
|
||||||
|
itemChild = {"id":"", "type":"", "title": parent, "parent": parent}
|
||||||
href = anchor.find("a").get("href")
|
href = anchor.find("a").get("href")
|
||||||
menu = self._child(parent, parent)
|
#menu = self._child(parent, parent)
|
||||||
if href == "#":
|
if href == "#":
|
||||||
li = anchor.find("ul").find_all("li")
|
li = anchor.find("ul").find_all("li")
|
||||||
for child in li:
|
for child in li:
|
||||||
a = child.find("a")
|
a = child.find("a")
|
||||||
self._logger.info("{0} {1} : {2}".format(self._name, anchor.find("a").get_text(), a.get_text()))
|
self._logger.info("{0} Parent {1} : Child {2}".format(self._name, parent, a.get_text()))
|
||||||
children.append(self._child(a.get_text(), parent))
|
itemChild["title"] = a.get_text()
|
||||||
self._logger.info(children)
|
itemChild["parent"] = parent
|
||||||
menu["children"] = children
|
itemMenu["children"].append(itemChild)
|
||||||
menus.append(menu)
|
menu.append(itemMenu)
|
||||||
for i in range(0, len(menus)-1):
|
|
||||||
self._logger.info("{0} : Menu : {1} {2}".format(self._name, menus[i], len(parents)))
|
|
||||||
for j in range(0, len(parents)-1):
|
|
||||||
#self._logger.info("{0} : Comparaison : {1} {2}".format(self._name, menu[i]["title"], parents[j]))
|
|
||||||
|
|
||||||
if menus[i]["title"] == parents[j]:
|
|
||||||
self._logger.info("{0} del : {1}".format(self._name, parents[j]))
|
|
||||||
del parents[j]
|
|
||||||
|
|
||||||
for i in parents:
|
for i in range(0, len(menu)-1):
|
||||||
self._logger.info("{0} : Parent : {1}".format(self._name, i))
|
self._logger.info("{0} Menu : {1}".format(self._name, menu[i]))
|
||||||
|
#for j in menu[i]["children"]:
|
||||||
|
# if menu[i]["title"] == j["title"]:
|
||||||
|
# del menu[i]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user