Kryana Nicolayi on Nostr: ...
一応収集スクリプトおいておくのでmisskey.04.siのところを変えてご自由にお使いください
from publicsuffix2 import fetch, get_tld
import requests
from pprint import pprint
from time import sleep
psl_file = fetch()
length = 9000
headers = {
'Content-Type': 'application/json',
}
hosts = {}
cnt = 0
for i in range(0,length + 1,10):
json_data = {
'limit': 10,
'offset': i,
}
response = requests.post('https://misskey.04.si/api/federation/instances';, headers=headers, json=json_data).json()
if (response == []):
break
for r in response:
cnt+=1
domain = r["host"]
tld = get_tld(domain, psl_file=psl_file)
print(f"domain:{domain} tld:{tld}")
if (tld in hosts):
hosts[tld] += 1
else:
hosts[tld] = 1
sleep(5)
hosts = sorted(hosts.items(),key=lambda x:x[1],reverse=True)
with open("result.txt","w") as f:
for tld, count in hosts:
f.write(f"{tld}: {count}\n")
pprint(hosts)
print(f"total server:{cnt}")
from publicsuffix2 import fetch, get_tld
import requests
from pprint import pprint
from time import sleep
psl_file = fetch()
length = 9000
headers = {
'Content-Type': 'application/json',
}
hosts = {}
cnt = 0
for i in range(0,length + 1,10):
json_data = {
'limit': 10,
'offset': i,
}
response = requests.post('https://misskey.04.si/api/federation/instances';, headers=headers, json=json_data).json()
if (response == []):
break
for r in response:
cnt+=1
domain = r["host"]
tld = get_tld(domain, psl_file=psl_file)
print(f"domain:{domain} tld:{tld}")
if (tld in hosts):
hosts[tld] += 1
else:
hosts[tld] = 1
sleep(5)
hosts = sorted(hosts.items(),key=lambda x:x[1],reverse=True)
with open("result.txt","w") as f:
for tld, count in hosts:
f.write(f"{tld}: {count}\n")
pprint(hosts)
print(f"total server:{cnt}")