From 8679f43fd820361ed8bbcdbc02e851a4975ac76d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 17 Jul 2023 15:24:30 +0200 Subject: [PATCH] Continued: - rewrote a bit for better logging - also don't nest function/method invocations, they are not easy to debug --- fba/networks/friendica.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fba/networks/friendica.py b/fba/networks/friendica.py index e3fdb71..b4cded1 100644 --- a/fba/networks/friendica.py +++ b/fba/networks/friendica.py @@ -41,24 +41,25 @@ def fetch_blocks(domain: str) -> list: try: logger.debug("Fetching friendica blocks from domain='%s'", domain) - doc = bs4.BeautifulSoup( - network.fetch_response( - domain, - "/friendica", - network.web_headers, - (config.get("connection_timeout"), config.get("read_timeout")) - ).text, - "html.parser", - ) + raw = network.fetch_response( + domain, + "/friendica", + network.web_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ).text + logger.debug("Parsing %d Bytes ...", len(raw)) + + doc = bs4.BeautifulSoup(raw, "html.parser",) logger.debug("doc[]='%s'", type(doc)) block_tag = doc.find(id="about_blocklist") + logger.debug("block_tag[%s]='%s'", type(block_tag), block_tag) except network.exceptions as exception: logger.warning("Exception '%s' during fetching instances from domain='%s'", type(exception), domain) instances.set_last_error(domain, exception) return list() - # Prevents exceptions: + logger.debug("block_tag[%s]='%s'", type(block_tag), block_tag) if block_tag is None: logger.debug("Instance has no block list: domain='%s'", domain) return list() -- 2.39.5