Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
codejake committed Jan 17, 2025
1 parent 9530d6e commit 56a42ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions generate.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Uses maxmind.com databases (free)
import geoip2.database

# This is super sloppy, sorry. You should know how to Python in order to use
# This is super sloppy, sorry. You should know how to Python in order to use
# this. Feel free to bug me in the usual spots if you have a question.
with (
geoip2.database.Reader('./GeoLite2-City.mmdb') as city_reader,
Expand All @@ -15,6 +15,7 @@
try:
cr = city_reader.city(ip)
ar = asn_reader.asn(ip)
print(f"{ip},{ar.autonomous_system_number},{ar.autonomous_system_organization},{cr.city.name},{cr.subdivisions.most_specific.name},{cr.country.iso_code}")
print(f"{ip},{ar.autonomous_system_number},{ar.autonomous_system_organization},{cr.city.name},"
f"{cr.subdivisions.most_specific.name},{cr.country.iso_code}")
except geoip2.errors.AddressNotFoundError:
print(f"{ip}: Unknown")

0 comments on commit 56a42ca

Please sign in to comment.