From: Roland Häder Date: Thu, 18 May 2023 01:23:59 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b6c24812513ba6b24e3b11a80d0b8bc95f440316;p=fba.git Continued: - ops, to happy with "fba." adding - added more debug lines --- 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)