about to change to dictionary for IPs in Country
This commit is contained in:
parent
f242e70afa
commit
1ecb7b5c77
@ -18,24 +18,22 @@ uniqueIPsByCountry = 0
|
|||||||
for login in loginList:
|
for login in loginList:
|
||||||
ipAddr = regex.split(ipAddrRegex, login)
|
ipAddr = regex.split(ipAddrRegex, login)
|
||||||
ip = ipAddr[1]
|
ip = ipAddr[1]
|
||||||
if ip in ipAddrList:
|
# use dictionary for number of IPs in a Country
|
||||||
country = geoip.country_code_by_addr(ip)
|
country = geoip.country_code_by_addr(ip)
|
||||||
if country not in ipAddrCountry.values():
|
if country not in ipAddrCountry.values():
|
||||||
uniqueIPsByCountry += 1
|
uniqueIPsByCountry += 1
|
||||||
|
ipAddrCountry[ip] = country
|
||||||
|
if ip in ipAddrList.keys():
|
||||||
ipAddrList[ip] += 1
|
ipAddrList[ip] += 1
|
||||||
else:
|
else:
|
||||||
country = geoip.country_code_by_addr(ip)
|
|
||||||
if country not in ipAddrCountry.values():
|
|
||||||
uniqueIPsByCountry += 1
|
|
||||||
ipAddrCountry[ip] = country
|
|
||||||
uniqueIPs+=1
|
uniqueIPs+=1
|
||||||
ipAddrList[ip] = 1
|
ipAddrList[ip] = 1
|
||||||
|
|
||||||
print("IP Addresses by count:")
|
print("\nIP Addresses by count:\n")
|
||||||
for ipCount in ipAddrList:
|
for ipCount in ipAddrList:
|
||||||
print(ipCount,":", ipAddrList.get(ipCount))
|
print(ipCount,":", ipAddrList.get(ipCount))
|
||||||
print("IP Addresses by country:")
|
print("\nIP Addresses by country:\n")
|
||||||
for ipCountry in ipAddrCountry:
|
for ipCountry in ipAddrCountry:
|
||||||
print(ipCountry, ":", ipAddrCountry.get(ipCountry))
|
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")
|
print("\nNumber of unique IP addresses by Country: ", uniqueIPsByCountry, "\n")
|
Loading…
Reference in New Issue
Block a user