This commit is contained in:
Jing Ling
2020-07-23 14:03:15 +08:00
parent 0901bb1308
commit b003bcf90f
+4 -4
View File
@@ -14,8 +14,8 @@ class Entry(object):
class IPAsnData(object): class IPAsnData(object):
def __init__(self): def __init__(self):
zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-ASN.CSV.ZIP") zip_path = data_storage_dir.joinpath('IP2LOCATION-LITE-ASN.CSV.ZIP')
csv_path = data_storage_dir.joinpath("IP2LOCATION-LITE-ASN.CSV") csv_path = data_storage_dir.joinpath('IP2LOCATION-LITE-ASN.CSV')
if csv_path.exists(): if csv_path.exists():
asn_fp = open(csv_path) asn_fp = open(csv_path)
else: else:
@@ -63,10 +63,10 @@ class IPAsnInfo(object):
def find(self, ip): def find(self, ip):
asn = self.asn.find(ip) asn = self.asn.find(ip)
if asn: if asn:
result = {"cidr": asn[2], "asn": f'AS{asn[3]} {asn[4]}'} result = {'cidr': asn[2], 'asn': f'AS{asn[3]} {asn[4]}'}
return result return result
else: else:
return None return {'cidr': '', 'asn': ''}
if __name__ == "__main__": if __name__ == "__main__":