]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 15 Jan 2025 02:12:11 +0000 (03:12 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 15 Jan 2025 02:12:11 +0000 (03:12 +0100)
- need to skip invalid table headers, they should be introduced with <thead>
  and then each column <th> but some website may use <tr> instead of <thead>
- strip (trim) strings

fba/networks/friendica.py
fba/networks/pleroma.py

index fcf9e5c1d14e2fe99b0fd906665449b07234f26c..4d252e114c566a81329bc073708c944091019057 100644 (file)
@@ -87,6 +87,10 @@ def fetch_blocks(domain: str) -> list:
         tds = line.find_all("td")
 
         logger.debug("tds[%s]()=%d", type(tds), len(tds))
+        if len(tds) == 0:
+            logger.warning("No 'td' tag found in line[]='%s' - SKIPPED!", type(line))
+            continue
+
         blocked = tds[0].text.strip()
         reason  = tds[1].text.strip()
 
index 1d983327796cf213d064ce8ec75e37821dbdd268..3cfa9a632e89f153ca49d840bb55aaf374f70593 100644 (file)
@@ -376,8 +376,12 @@ def fetch_blocks_from_about(domain: str) -> dict:
                 tds = line.find_all("td")
 
                 logger.debug("tds[%s]()=%d", type(tds), len(tds))
-                blocked = tds[0].text
-                reason  = tds[1].text
+                if len(tds) == 0:
+                    logger.warning("No 'td' tag found in line[]='%s' - SKIPPED!", type(line))
+                    continue
+
+                blocked = tds[0].text.strip()
+                reason  = tds[1].text.strip()
 
                 logger.debug("blocked='%s',reason='%s' - BEFORE!", blocked, reason)
                 blocked = tidyup.domain(blocked) if blocked != "" else None