import requests
import json
import time
f1 = open('ip.txt','r',encoding='UTF-8')
for i in f1:
url = 'http://ip-api.com/json/%s' %str(i.strip('\n'))
print(url)
requ = requests.get('http://ip-api.com/json/%s' %str(i.strip('\n'))).content.decode("utf-8")
print(requ)
json1 = json.loads(requ)
with open('log.txt', 'a', encoding='utf-8') as f:
text = str(i.strip('\n')) + '\n' + json1['country'] + '\n' + json1['regionName'] + '\n' + json1['isp'] + '\n'+'---------------------------------------' + '\n'
f.write(text)
time.sleep(3)
01-22
3279