add menu
This commit is contained in:
parent
9d41e57379
commit
d9c20cedcb
@ -86,18 +86,21 @@ class WPMenu:
|
|||||||
idMenu = {"id":0, "type":"", "link":""}
|
idMenu = {"id":0, "type":"", "link":""}
|
||||||
soup = BeautifulSoup(content, self._parser)
|
soup = BeautifulSoup(content, self._parser)
|
||||||
articletitle = soup.find("h2", class_="articletitle").get_text()
|
articletitle = soup.find("h2", class_="articletitle").get_text()
|
||||||
|
search = "posts"
|
||||||
if len(articletitle) == 0:
|
if len(articletitle) == 0:
|
||||||
articletitle = soup.find("div", class_="albumbody").find("h2").get_text()
|
articletitle = soup.find("div", class_="albumbody").find("h2").get_text()
|
||||||
|
search = "pages"
|
||||||
|
|
||||||
exist = False
|
exist = False
|
||||||
for index in range(1,10):
|
for index in range(1,10):
|
||||||
if exist is False:
|
if exist is False:
|
||||||
params = {"search":articletitle, "per_page":100, "page":index}
|
params = {"search":articletitle, "per_page":100, "page":index}
|
||||||
try:
|
try:
|
||||||
self._logger.debug("{0} : Get Url for post : {1} {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/posts".format(self._wordpress, self._protocol_wordpress), params))
|
self._logger.debug("{0} : Get Url for {3} : {1} {2}".format(self._name, "{1}://{0}/wp-json/wp/v2/{2}".format(self._wordpress, self._protocol_wordpress, search), params, search))
|
||||||
page = self._request_wordpress.get("{1}://{0}/wp-json/wp/v2/posts".format(self._wordpress, self._protocol_wordpress), auth=self._basic, params=params)
|
page = self._request_wordpress.get("{1}://{0}/wp-json/wp/v2/{2}".format(self._wordpress, self._protocol_wordpress, search), auth=self._basic, params=params)
|
||||||
if page.status_code == 200:
|
if page.status_code == 200:
|
||||||
result = page.json()
|
result = page.json()
|
||||||
self._logger.info("{0} : Get content post : {1}".format(self._name, len(result)))
|
self._logger.info("{0} : Get content {2} : {1}".format(self._name, len(result), search))
|
||||||
if len(result) > 0:
|
if len(result) > 0:
|
||||||
for i in result:
|
for i in result:
|
||||||
title_rendered = i["title"]["rendered"]
|
title_rendered = i["title"]["rendered"]
|
||||||
@ -105,7 +108,7 @@ class WPMenu:
|
|||||||
title_rendered = self._replaceCaracter(title_rendered)
|
title_rendered = self._replaceCaracter(title_rendered)
|
||||||
self._logger.debug("{0} : comparaison debug {1} {2}".format(self._name, articletitle, title_rendered))
|
self._logger.debug("{0} : comparaison debug {1} {2}".format(self._name, articletitle, title_rendered))
|
||||||
if articletitle == title_rendered:
|
if articletitle == title_rendered:
|
||||||
self._logger.debug("{0} : get post id : {1}".format(self._name, i))
|
self._logger.debug("{0} : get {2} id : {1}".format(self._name, i, search))
|
||||||
idMenu = {"id":i["id"], "type":"post", "link": i["link"]}
|
idMenu = {"id":i["id"], "type":"post", "link": i["link"]}
|
||||||
exist = True
|
exist = True
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user