1
0

about to change to dictionary for IPs in Country

This commit is contained in:
Andrew Woodlee 2022-11-17 00:18:53 -06:00
parent f242e70afa
commit 1ecb7b5c77

View File

@ -18,24 +18,22 @@ uniqueIPsByCountry = 0
for login in loginList:
ipAddr = regex.split(ipAddrRegex, login)
ip = ipAddr[1]
if ip in ipAddrList:
country = geoip.country_code_by_addr(ip)
if country not in ipAddrCountry.values():
uniqueIPsByCountry += 1
# use dictionary for number of IPs in a Country
country = geoip.country_code_by_addr(ip)
if country not in ipAddrCountry.values():
uniqueIPsByCountry += 1
ipAddrCountry[ip] = country
if ip in ipAddrList.keys():
ipAddrList[ip] += 1
else:
country = geoip.country_code_by_addr(ip)
if country not in ipAddrCountry.values():
uniqueIPsByCountry += 1
ipAddrCountry[ip] = country
uniqueIPs+=1
ipAddrList[ip] = 1
print("IP Addresses by count:")
print("\nIP Addresses by count:\n")
for ipCount in ipAddrList:
print(ipCount,":", ipAddrList.get(ipCount))
print("IP Addresses by country:")
print("\nIP Addresses by country:\n")
for ipCountry in ipAddrCountry:
print(ipCountry, ":", ipAddrCountry.get(ipCountry))
print("\nNumber of unique IP addresses: ", uniqueIPs, "\n")
print("\nNumber of unique IP addresses: ", uniqueIPs)
print("\nNumber of unique IP addresses by Country: ", uniqueIPsByCountry, "\n")