-
-
Save anonymous/548fa59fabe8a7ee2b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lookup(query) | |
query = URI.parse(query).host ||= query | |
geoInfo = @geo.city(query) | |
asnInfo = @isp.asn(query) | |
p geoInfo # <struct GeoIP::City request="google.com", ip="208.117.229.217", country_code2="US", country_code3="USA", country_name="United States", continent_code="NA", region_name="CA", city_name="Mountain View", postal_code="94043", latitude=37.41919999999999, longitude=-122.0574, dma_code=807, area_code=650, timezone="America/Los_Angeles", real_region_name="California"> | |
geoInfo.each do |v| # ERROR | |
p v | |
end | |
"%s [%s/%s] %s [%s/%s]" % [ | |
geoInfo.ip, | |
geoInfo.country_name, | |
geoInfo.real_region_name, | |
geoInfo.city_name, | |
asnInfo.asn, | |
asnInfo.number | |
] | |
rescue Exception => e | |
"error; #{e}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment