Estatística de Servidores Mastodon Brasileiros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |
Total de usuários: 1941
Total de Servidores ativos: 28
Total de Servidores abertos: 17
Total de usuários: 2290
Total de Servidores ativos: 25
Total de Servidores abertos: 14
Total de usuários: 1780
Total de Servidores pesquisados: 32
Total de Servidores ativos: 26
Total de Servidores abertos: 13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1933 usuários