时间:2023-02-13 08:06:01 | 来源:建站知识
时间:2023-02-13 08:06:01 来源:建站知识
IP查询的APIimport requestsimport json# IP address to testip_address = '147.229.2.90'request_url = 'https://geolocation-db.com/jsonp/' + ip_addressresponse = requests.get(request_url)result = response.content.decode()result = result.split("(")[1].strip(")")result = json.loads(result)print(result)
import socketdef URL2IP(): for oneurl in urllist.readlines(): url=str(oneurl.strip())[7:] print url try: ip =socket.gethostbyname(url) print ip iplist.writelines(str(ip)+"/n") except: print "this URL 2 IP ERROR "try: urllist=open("D:/urllist.txt","r") iplist=open("D:/iplist.txt","w") URL2IP() urllist.close() iplist.close() print "complete !"except: print "ERROR !"
Python--域名解析成IP地址_LandGrey的博客-CSDN博客_python解析域名ip关键词:判断,国家,属地