X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=fetch_instances.py;h=e6090353e4e75fbdb2c03e579714ae1367b9a0db;hb=11df2bc51171199088a0e513b9e5c6a1340953ff;hp=2d12351faefc307721592e087d1f548b9c0fb3c5;hpb=deee4b248da73c9082325304ca340ccc6df19476;p=fba.git diff --git a/fetch_instances.py b/fetch_instances.py index 2d12351..e609035 100644 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -7,7 +7,7 @@ import json domain = sys.argv[1] headers = { - "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" + "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0" } @@ -27,6 +27,8 @@ peerlist = get_peers(domain) def get_type(instdomain: str) -> str: try: res = get(f"https://{instdomain}/nodeinfo/2.1.json", headers=headers, timeout=5) + if res.status_code == 404: + res = get(f"https://{instdomain}/nodeinfo/2.0", headers=headers, timeout=5) if res.status_code == 404: res = get(f"https://{instdomain}/nodeinfo/2.0.json", headers=headers, timeout=5) if res.ok and "text/html" in res.headers["content-type"]: @@ -34,6 +36,10 @@ def get_type(instdomain: str) -> str: if res.ok: if res.json()["software"]["name"] == "akkoma": return "pleroma" + elif res.json()["software"]["name"] == "hometown": + return "mastodon" + elif res.json()["software"]["name"] == "ecko": + return "mastodon" else: return res.json()["software"]["name"] elif res.status_code == 404: @@ -52,8 +58,12 @@ c.execute( ) for instance in peerlist: + instance = instance.lower() print(instance) try: + c.execute( + "select domain from instances where domain = ?", (instance,) + ) if c.fetchone() == None: c.execute( "insert into instances select ?, ?, ?", @@ -61,5 +71,5 @@ for instance in peerlist: ) conn.commit() except Exception as e: - print("error:", e, blocker) + print("error:", e, instance) conn.close()