medved/bin/gen-ranges.py
Good Evening d782c2eb70 pew pew
2018-04-03 01:41:10 +03:00

14 lines
305 B
Python
Executable File

import netaddr as n
import requests as r
# country two letter code
cn = 'ru'
# list of networks
nets = [n.IPNetwork(net.decode('ascii')) for net in r.get('http://www.cc2asn.com/data/%s_ipv4' % cn).iter_lines()]
for net in nets:
print(str(n.IPAddress(net.first)) + '-' + str(n.IPAddress(net.last)))