cf_speedtest 0.5.0

A command-line internet speed test tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests

r = requests.get("https://speed.cloudflare.com/locations")
locs_json = r.json()

sorted_data = sorted(locs_json, key=lambda x: x['cca2'], reverse=False)

map_code = ""

for entry in sorted_data:
    iata = entry["iata"]
    city = entry["city"]
    cca2 = entry["cca2"]
    map_code += f'map.insert("{iata}", ("{city}", "{cca2}"));\n'

print(map_code)
with open('output.rs', 'w', encoding="utf-8") as file:
    file.write(map_code)