Skip to content

Instantly share code, notes, and snippets.

@josircg
Last active March 11, 2024 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josircg/2a39af7f929c588627f917afa17459c4 to your computer and use it in GitHub Desktop.
Save josircg/2a39af7f929c588627f917afa17459c4 to your computer and use it in GitHub Desktop.
Estatística de Servidores Mastodon Brasileiros
#!/usr/bin/env python
import requests
server_list = ('ursal.zone', 'bolha.us', 'colorid.es',
'mastodon.com.br', 'masto.donte.com.br', 'conversafiada.net', 'cwb.social', 'burnthis.town',
'piupiupiu.com.br', 'vira-lata.org', 'clube.social', 'bantu.social', 'cuscuz.in',
'komuna.digital', 'fim.social', 'social.br-linux.org', 'ayom.media', 'bertha.social',
'vox.mojo', 'bolha.one', 'oxente.club', 'nuvem.lgbt', 'mastodon.yurialbuquerque.dev',
'social.modscleo4.dev.br', 'botequim.social', 'mstdn.facb69.com.br',
'social.coletivos.org',
'aengus.ddnsgeek.com', 'mastodon.brigadadigital.tec.br', 'mastodon.girino.org',
'masto.lema.org', 'unipar.online',
)
tot_usuarios = 0
tot_abertos = 0
tot_ativos = 0
resultset = []
for server in server_list:
print(f'Buscando dados de {server}')
try:
response = requests.get(f"https://{server}/api/v2/instance", timeout=30)
if response.status_code == 200:
result = response.json()
resultset.append((server,
result['usage']['users']['active_month'],
result['registrations']['enabled'],
response.elapsed.total_seconds()
)
)
tot_usuarios += result['usage']['users']['active_month']
tot_ativos += 1
if result['registrations']['enabled']:
tot_abertos += 1
else:
response = None
except requests.exceptions.ConnectionError:
response = None
if not response:
print(f'Servidor {server} fora do ar')
tot_pesquisados = len(server_list)
print(f'\nTotal de usuários: {tot_usuarios}')
print(f'\nTotal de Servidores pesquisados: {tot_pesquisados}')
print(f'\nTotal de Servidores ativos: {tot_ativos}')
print(f'\nTotal de Servidores abertos: {tot_abertos}')
resultset.sort(key=lambda a: a[1], reverse=True)
for registro in resultset:
print('%s. Usuários: %s. Aceita novos: %s (%s)' % registro)
arquivo = open('mastodon.csv', 'w')
arquivo.write('"Servidor","Usuário"\n')
for registro in resultset:
arquivo.write('%s,%s\n' % (registro[0], registro[1]))
arquivo.close()
print('mastodon.csv gerado com sucesso')
@josircg
Copy link
Author

josircg commented Jun 8, 2023

1933 usuários

@josircg
Copy link
Author

josircg commented Jun 30, 2023

Total de usuários: 1941
Total de Servidores ativos: 28
Total de Servidores abertos: 17

@josircg
Copy link
Author

josircg commented Aug 2, 2023

Total de usuários: 2290
Total de Servidores ativos: 25
Total de Servidores abertos: 14

@josircg
Copy link
Author

josircg commented Sep 16, 2023

Total de usuários: 1780

Total de Servidores pesquisados: 32
Total de Servidores ativos: 26
Total de Servidores abertos: 13

@josircg
Copy link
Author

josircg commented Oct 29, 2023

Total de usuários: 1671

Total de Servidores pesquisados: 32
Total de Servidores ativos: 25
Total de Servidores abertos: 14

@josircg
Copy link
Author

josircg commented Mar 11, 2024

Total de usuários: 1355

Total de Servidores pesquisados: 32
Total de Servidores ativos: 22
Total de Servidores abertos: 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment