diff --git a/lib/WPMenu.py b/lib/WPMenu.py index 1bddf6e..b7bdcdf 100644 --- a/lib/WPMenu.py +++ b/lib/WPMenu.py @@ -86,18 +86,21 @@ class WPMenu: idMenu = {"id":0, "type":"", "link":""} soup = BeautifulSoup(content, self._parser) articletitle = soup.find("h2", class_="articletitle").get_text() + search = "posts" if len(articletitle) == 0: articletitle = soup.find("div", class_="albumbody").find("h2").get_text() + search = "pages" + exist = False for index in range(1,10): if exist is False: params = {"search":articletitle, "per_page":100, "page":index} 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)) - page = self._request_wordpress.get("{1}://{0}/wp-json/wp/v2/posts".format(self._wordpress, self._protocol_wordpress), auth=self._basic, params=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/{2}".format(self._wordpress, self._protocol_wordpress, search), auth=self._basic, params=params) if page.status_code == 200: 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: for i in result: title_rendered = i["title"]["rendered"] @@ -105,7 +108,7 @@ class WPMenu: title_rendered = self._replaceCaracter(title_rendered) self._logger.debug("{0} : comparaison debug {1} {2}".format(self._name, 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"]} exist = True else: