]> git.mxchange.org Git - fba.git/blobdiff - fba/networks/friendica.py
Continued:
[fba.git] / fba / networks / friendica.py
index f30f1263492318af0007716460e3398d91c43d70..1434697ae1ac06146eb4b78d79eb275e961c38ef 100644 (file)
@@ -70,7 +70,10 @@ def fetch_blocks(domain: str) -> list:
     table = block_tag.find("table")
 
     logger.debug("table[]='%s'", type(table))
-    if table.find("tbody"):
+    if table is None:
+        logger.warning("domain='%s' has no table tag - EXIT !", domain)
+        return list()
+    elif table.find("tbody"):
         rows = table.find("tbody").find_all("tr")
     else:
         rows = table.find_all("tr")
@@ -78,12 +81,15 @@ def fetch_blocks(domain: str) -> list:
     logger.debug("Found rows()=%d", len(rows))
     for line in rows:
         logger.debug("line='%s'", line)
-        blocked = tidyup.domain(line.find_all("td")[0].text)
+        blocked = line.find_all("td")[0].text
+        logger.debug("blocked='%s'", blocked)
+
+        blocked = tidyup.domain(blocked) if blocked != "" else None
         reason  = tidyup.reason(line.find_all("td")[1].text)
-        logger.debug("blocked='%s',reason='%s'", blocked, reason)
+        logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason)
 
-        if blocked == "":
-            logger.debug("line[]='%s' returned empty blocked domain - SKIPPED!", type(line))
+        if blocked is None or blocked == "":
+            logger.warning("line[]='%s' returned empty blocked domain - SKIPPED!", type(line))
             continue
         elif not domain_helper.is_wanted(blocked):
             logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
@@ -92,8 +98,8 @@ def fetch_blocks(domain: str) -> list:
         logger.debug("Appending blocked='%s',reason='%s'", blocked, reason)
         blocklist.append({
             "blocker"    : domain,
-            "blocked"    : tidyup.domain(blocked),
-            "reason"     : tidyup.reason(reason),
+            "blocked"    : blocked,
+            "reason"     : reason,
             "block_level": "reject",
         })