mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-03-26 03:13:09 +03:00
Get data actions
This commit is contained in:
26
get_info_from_ripe.py
Executable file
26
get_info_from_ripe.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
|
||||
url = "https://stat.ripe.net/data/country-resource-list/data.json?resource=RU&v4_format=prefix"
|
||||
|
||||
out_file_asn = "auto/all-ru-asn.txt"
|
||||
out_file_ipv4 = "auto/all-ru-ipv4.txt"
|
||||
out_file_ipv6 = "auto/all-ru-ipv6.txt"
|
||||
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
|
||||
with open(out_file_asn, 'w') as f:
|
||||
for asn in data['data']['resources']['asn']:
|
||||
f.write(str("AS"+asn) + '\n')
|
||||
|
||||
with open(out_file_ipv4, 'w') as f:
|
||||
for ipv4 in data['data']['resources']['ipv4']:
|
||||
f.write(str(ipv4) + '\n')
|
||||
|
||||
with open(out_file_ipv6, 'w') as f:
|
||||
for ipv6 in data['data']['resources']['ipv6']:
|
||||
f.write(str(ipv6) + '\n')
|
||||
Reference in New Issue
Block a user