import json from collections import Counter from urllib.request import urlopen, Request import time account_name = "danzin" # Put your account name between the quotes instance = "mastodon.social" # Put your instance between the quotes, without the https:// part def get_account_id(account_name, instance): account_url = f"https://{instance}/api/v1/accounts/lookup?acct={account_name}" account_result = urlopen(account_url).read().decode("utf-8") account_id = json.loads(account_result)["id"] return account_id def fetch_followers(account_id, instance): followers = [] followers_url = f"https://{instance}/api/v1/accounts/{account_id}/followers" while followers_url: request = Request(followers_url) response = urlopen(request) followers_result = response.read().decode("utf-8") followers.extend(json.loads(followers_result)) # Check for next page links = response.headers.get("Link", "") next_url = None if 'rel="next"' in links: for link in links.split(","): if 'rel="next"' in link: next_url = link.split(";")[0].strip("<> ") break followers_url = next_url if next_url: time.sleep(1) # Be kind to the server return followers account_id = get_account_id(account_name, instance) all_followers = fetch_followers(account_id, instance) print(f"Total followers retrieved: {len(all_followers)}") instances = [] for follower in all_followers: url = follower["url"] instances.append(url[8:url[8:].index("/") + 8]) counts = Counter(instances) print(f"{len(instances)} accounts in {len(counts)} instances.") print(f"{sum(x[1] for x in counts.most_common() if x[1] == 1)} single accounts in a instance.") print("\nFollower accounts per instance:") print("\n".join(f"{x[0]}: {x[1]}" for x in counts.most_common()))
Total followers retrieved: 585 585 accounts in 175 instances. 121 single accounts in a instance. Follower accounts per instance: mastodon.social: 157 fosstodon.org: 82 hachyderm.io: 26 ursal.zone: 24 bolha.one: 12 mstdn.social: 12 bolha.us: 11 mastodon.online: 7 tech.lgbt: 6 bertha.social: 6 infosec.exchange: 6 ayom.media: 5 aus.social: 5 mastodon.com.br: 5 masto.ai: 5 kolektiva.social: 4 indieweb.social: 4 chaos.social: 4 universeodon.com: 3 genomic.social: 3 mas.to: 3 toot.cat: 3 pynews.com.br: 3 techhub.social: 3 floss.social: 3 sigmoid.social: 3 conversafiada.net: 3 mastodon.gal: 3 bantu.social: 3 ioc.exchange: 2 panelinha.club: 2 wandering.shop: 2 mastodon.cloud: 2 mastodon.sdf.org: 2 rstats.me: 2 mastodon.world: 2 social.vivaldi.net: 2 astrodon.social: 2 toot.community: 2 masto.pt: 2 masto.donte.com.br: 2 nuvem.lgbt: 2 masto.es: 2 mastodon.me.uk: 2 mstdn.ca: 2 mastodon.art: 2 defcon.social: 2 allthingstech.social: 2 mstdn.facb69.com.br: 2 ciberlandia.pt: 2 fim.social: 2 octodon.social: 2 scicomm.xyz: 2 social.treehouse.systems: 2 nheko.io: 1 social.stealthy.club: 1 pleroma.indymnv.xyz: 1 circumstances.run: 1 social.python-gsoc.org: 1 oldbytes.space: 1 twit.social: 1 mastodon.nl: 1 infosec.space: 1 social.afront.org: 1 queer.party: 1 social.joelle.us: 1 turtleisland.social: 1 social.harpia.red: 1 toot.ozor.es: 1 social.pu2ttz.app.br: 1 rascalking.com: 1 bencarneiro.com: 1 social.jeronimo.dev.br: 1 framapiaf.org: 1 kind.social: 1 friend.camp: 1 xantronix.social: 1 mastodon.matrix.org: 1 mastodon.stevex.online: 1 mastodon.nz: 1 pkm.social: 1 fediverse.fun: 1 untrusted.website: 1 mamot.fr: 1 mstdn.plus: 1 artsocial.boston: 1 ottawa.place: 1 catodon.social: 1 diaspora.im: 1 c.im: 1 mast.lat: 1 plasmatrap.com: 1 mastodon.top: 1 mastodon.gamedev.place: 1 todon.eu: 1 mastodonapp.uk: 1 scholar.social: 1 pdx.social: 1 weatherishappening.network: 1 datasci.social: 1 pebble.social: 1 mathstodon.xyz: 1 transfem.social: 1 mastodon.coffee: 1 graphics.social: 1 social.linux.pizza: 1 mastodon.au: 1 data-folks.masto.host: 1 fearness.org: 1 snac.bsd.cafe: 1 beige.party: 1 mstdn.mx: 1 dragonscave.space: 1 wetdry.world: 1 hostux.social: 1 mastodon.ie: 1 mast.hpc.social: 1 pancake.place: 1 az.social: 1 twiukraine.com: 1 mastodon.longlandclan.id.au: 1 fedi.askiiart.net: 1 fsmi.social: 1 discuss.systems: 1 toot.berlin: 1 metalhead.club: 1 social.saarland: 1 bardown.space: 1 toot.wales: 1 norden.social: 1 xoxo.zone: 1 furry.engineer: 1 social.sdf.org: 1 tkz.one: 1 pilote.me: 1 sunny.garden: 1 ngmx.com: 1 mstdn.science: 1 infosec.town: 1 social.davidbrush.info: 1 pixelfed.social: 1 botsin.space: 1 firefish.tech: 1 blackqueer.life: 1 social.arunmozhi.in: 1 lethallava.land: 1 vira-lata.org: 1 firefish.social: 1 fedi.hyperreal.coffee: 1 cutie.city: 1 masto.lema.org: 1 rebel.ar: 1 mastodont.cat: 1 argonauten.space: 1 geekstodon.com: 1 pixelfed.de: 1 toot.cafe: 1 vis.social: 1 mastodon.acm.org: 1 social.ahlcode.fi: 1 fediscience.org: 1 eightpoint.app: 1 social.jacklinke.com: 1 social.teia.bio.br: 1 ff.swrlab.org: 1 me.dm: 1 recurse.social: 1 eigenmagic.net: 1 noc.social: 1 mastodon.bsd.cafe: 1 linuxrocks.online: 1 mastodon.la: 1 writing.exchange: 1 vmst.io: 1 social.learntosolveit.com: 1