ex = './tmp/ip_search_result.rsc'
url = f"https://api.bgpview.io/asn/{country}/prefixes"
r = requests.get(url)
with open(ex, 'w') as f:
f.write(r.text)
with open(ex, 'r') as f:
contents = json.loads(f.read())
my_file = open(ex, 'w')
for i in contents['data']['ipv4_prefixes']:
my_file.write(str(i['prefix'] + "\n"))
my_file.close()
await message.reply_document(open(ex, 'rb'))
os.remove(ex)
with open('file.txt') as f:
while True:
string = f.readline()
if string == '':
break
your_func(string)
with open('your_file.txt') as f:
txt = f.read().split()
for elem in txt:
your_func(elem)