From b6c24812513ba6b24e3b11a80d0b8bc95f440316 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 18 May 2023 03:23:59 +0200 Subject: [PATCH] Continued: - ops, to happy with "fba." adding - added more debug lines --- fetch_blocks.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fetch_blocks.py b/fetch_blocks.py index 32449ec..b241fa1 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -118,18 +118,22 @@ for blocker, software in fba.c.fetchall(): } # handling CSRF, I've saw at least one server requiring it to access the endpoint + print("DEBUG: Fetching meta:", blocker) meta = bs4.BeautifulSoup( reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=5).text, "html.parser", ) try: csrf = meta.find("meta", attrs={"name": "csrf-token"})["content"] - reqfba.headers = {**fba.headers, **{"x-csrf-token": csrf}} + print("DEBUG: Adding CSRF token:", blocker, csrf) + reqheaders = {**fba.headers, **{"x-csrf-token": csrf}} except: - reqfba.headers = fba.headers + print("DEBUG: No CSRF token found, using normal headers:", blocker) + reqheaders = fba.headers + print("DEBUG: Quering API domain_blocks:", blocker) blocks = reqto.get( - f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqfba.headers, timeout=5 + f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=5 ).json() print("DEBUG: blocks():", len(blocks)) @@ -148,9 +152,12 @@ for blocker, software in fba.c.fetchall(): else: print("WARNING: Unknown severity:", block['severity'], block['domain']) except: + print("DEBUG: Failed, Trying mastodon-specific fetches:", blocker) json = fba.get_mastodon_blocks(blocker) + print("DEBUG: json.items():", blocker, len(json.items())) for block_level, blocks in json.items(): + print("DEBUG: blocker,block_level,blocks():", blocker, block_level, len(blocks)) for instance in blocks: blocked, blocked_hash, reason = instance.values() print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason) -- 2.39.5