User:MalnadachBot/expand ip.py
Appearance
import ipaddress
import json
def get_ip_from_subnet(ip_subnet):
ips = ipaddress.ip_network(ip_subnet)
ip_list = ["* [[User talk:" + str(ip) + "]]" for ip in ips]
return ip_list
f = open('trimmed_ip.json')
data = json.load(f)
for ip_subnet in data['rows']:
try:
ip_list = get_ip_from_subnet(ip_subnet[0])
with open('ip_list.txt', 'a') as f:
for ip in ip_list:
f.write(ip)
f.write('\n')
except ValueError:
continue
f.close()