]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 11 Jul 2023 12:26:58 +0000 (14:26 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 11 Jul 2023 12:26:58 +0000 (14:26 +0200)
- need to find all, not just first element ...

fba/networks/lemmy.py

index 238f673c7fc4945a408d5efb30eacd8f8599a393..3d9983866bbcebce0a8d639fa2121b948812e57c 100644 (file)
@@ -152,23 +152,22 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list:
                 logger.debug("Checking %d header(s) ...", len(headers))
                 for header in headers:
                     logger.debug("header[]='%s'", type(header))
-                    content = header.find(["h2", "h3", "h4", "h5"])
-
-                    logger.debug("content[%s]='%s' - BEFORE!", type(content), content)
-                    if content is not None:
-                        content = content.contents[0]
-                    logger.debug("content[%s]='%s' - AFTER!", type(content), content)
-
-                    if content is None:
-                        logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header)
-                        continue
-                    elif not isinstance(content, str):
-                        logger.debug("content[]='%s' is not supported/wanted type 'str' - SKIPPED!", type(content))
-                        continue
-                    elif content.lower() in translations:
-                        logger.debug("Found header with blocked instances - BREAK!")
-                        found = header
-                        break
+                    for content in header.find_all(["h2", "h3", "h4", "h5"]): 
+                        logger.debug("content[%s]='%s' - BEFORE!", type(content), content)
+                        if content is not None:
+                            content = str(content.contents[0])
+                        logger.debug("content[%s]='%s' - AFTER!", type(content), content)
+
+                        if content is None:
+                            logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header)
+                            continue
+                        elif not isinstance(content, str):
+                            logger.debug("content[]='%s' is not supported/wanted type 'str' - SKIPPED!", type(content))
+                            continue
+                        elif content.lower() in translations:
+                            logger.debug("Found header with blocked instances - BREAK!")
+                            found = header
+                            break
 
             logger.debug("found[]='%s'", type(found))
             if found is None: