From bd8ac241c1253c60c587da2c426b39a6a291cf9a Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 16 Apr 2023 19:32:00 +0200 Subject: [PATCH] debug level comment --- lib/WPImport.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/WPImport.py b/lib/WPImport.py index a39e42e..5cd0ac7 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -226,6 +226,7 @@ class WPimport: ## Check class name def _hasClassName(self, tag, className): + print(tag["class"]) for i in tag["class"]: if i == className: return True @@ -243,8 +244,8 @@ class WPimport: def _getComment(self, comment): comment_post = [] - for i in comment: - comment_div = find_all("div", class_="comment_item")[0] + for i in range(0, len(comment)): + comment_div = comment[i].find("div", class_="comment_item") comment_item = comment_div.text.split("\n") footer = comment_div.find_all("div", class_="itemfooter") comment_author = footer[0].text.split(",")[0].replace("Posté par ", "") @@ -256,15 +257,17 @@ class WPimport: comment_content = comment_content + "

" parent = -1 parent_class = "level-1" - if self._hasClassName(i, parent_class) is False: + print(self._hasClassName(comment[i], parent_class)) + if self._hasClassName(comment[i], parent_class) is False: block = False - className = self._getClassName(tag, "level-").split("-") + className = self._getClassName(comment[i], "level-").split("-") level = 1 if len(className) > 0: level = int(className[1]) for j in range(i-1, 0): if block is False: levelName = "level-{0}".format(level - 1) + print(levelName) if self._hasClassName(comment[j], levelName): parent = j parent_class = levelName @@ -334,6 +337,7 @@ class WPimport: list_img.append(new_img) comment_post = self._getComment(comment) + exit(0) a = itemfooter[0].find_all("a", {"rel": True}) for i in a: