python实现ip地址查询(淘宝API)

python实现ip地址查询(淘宝API),第1张

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)

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/567739.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-09
下一篇2022-04-09

发表评论

登录后才能评论

评论列表(0条)

    保存