From: Roland Häder Date: Sat, 17 Jun 2023 08:45:45 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4e166b5ef6171eb9b94fe480e2bf2a70fc31dbb4;p=fba.git Continued: - need to handle requests.exceptions.InvalidSchema as well - if variable link is not dict or does not contain 'rel' attribute for what reason, then skip this --- diff --git a/fba/federation.py b/fba/federation.py index e79c69e..eebbfd7 100644 --- a/fba/federation.py +++ b/fba/federation.py @@ -311,8 +311,10 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: if "links" in nodeinfo: # DEBUG: print("DEBUG: Found links in nodeinfo():", len(nodeinfo["links"])) for link in nodeinfo["links"]: - # DEBUG: print("DEBUG: rel,href:", link["rel"], link["href"]) - if link["rel"] in nodeinfo_identifier: + # DEBUG: print(f"DEBUG: link[{type(link)}]='{link}'") + if not isinstance(link, dict) or not "rel" in link: + print(f"WARNING: link[]='{type(link)}' is not 'dict' or no element 'rel' found") + elif link["rel"] in nodeinfo_identifier: # DEBUG: print("DEBUG: Fetching nodeinfo from:", link["href"]) data = network.fetch_api_url( link["href"], @@ -367,7 +369,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: software = tidyup.domain(generator.get("content")) print(f"INFO: domain='{domain}' is generated by '{software}'") instances.set_detection_mode(domain, "GENERATOR") - elif isinstance(site_name, bs4.element.Tag): + elif isinstance(site_name, bs4.element.Tag) and isinstance(site_name.get("content"), str): # DEBUG: print("DEBUG: Found property=og:site_name:", domain) sofware = tidyup.domain(site_name.get("content")) print(f"INFO: domain='{domain}' has og:site_name='{software}'") diff --git a/fba/network.py b/fba/network.py index 5a404a4..38e37f1 100644 --- a/fba/network.py +++ b/fba/network.py @@ -38,6 +38,7 @@ api_headers = { exceptions = ( requests.exceptions.ChunkedEncodingError, requests.exceptions.ConnectionError, + requests.exceptions.InvalidSchema, requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, UnicodeEncodeError