-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/python | ||
|
||
import GeoIP | ||
|
||
gi = GeoIP.open("/usr/local/share/GeoIP/GeoIPCityConfidenceDist.dat",GeoIP.GEOIP_STANDARD) | ||
|
||
gir = gi.record_by_name("www.google.com") | ||
#gir = gi.record_by_addr("24.24.24.24") | ||
|
||
if gir != None: | ||
print gir['country_code'] | ||
print gir['country_code3'] | ||
print gir['country_name'] | ||
print gir['city'] | ||
print gir['region'] | ||
print gir['region_name'] | ||
print gir['postal_code'] | ||
print gir['latitude'] | ||
print gir['longitude'] | ||
print gir['area_code'] | ||
print gir['time_zone'] | ||
print gir['metro_code'] | ||
print gir['country_conf'] | ||
print gir['region_conf'] | ||
print gir['city_conf'] | ||
print gir['postal_conf'] | ||
print gir['accuracy_radius'] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
|
||
import GeoIP | ||
|
||
# open the citydatabase. All cities return in iso-8859-1 by default | ||
gi = GeoIP.open("/usr/local/share/GeoIP/GeoIPCity.dat",GeoIP.GEOIP_STANDARD) | ||
|
||
# lookup a record, where cityname contains chars > 127 ( eg != ascii ) | ||
gir = gi.record_by_name("www.osnabrueck.de") | ||
|
||
# print the cityname with iso-8859-1 charset | ||
print gir['city']; | ||
|
||
# print the cityname transformed to utf8 | ||
print unicode(gir['city'], 'iso-8859-1') | ||
|
||
# however, at your option GeoIP can return the cityname in utf8 | ||
# just put GeoIP into utf8 mode | ||
# | ||
# from now on all records returns in UTF8 until you change the charset again | ||
# Notice, that all previous records return in the previous charset | ||
gi.set_charset(GeoIP.GEOIP_CHARSET_UTF8); | ||
|
||
# get a new record, now in utf8 | ||
gir2 = gi.record_by_name("www.osnabrueck.de") | ||
|
||
# and print it ( should be the same output as on line 2 ) | ||
print gir2['city'] | ||
|
||
## Some more charset examples | ||
# current_charset = gi.charset() | ||
# old_charset = gi.set_charset(GeoIP.GEOIP_CHARSET_ISO_8859_1); | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/python | ||
|
||
import GeoIP | ||
|
||
gi = GeoIP.open("/usr/local/share/GeoIP/GeoIPNetSpeedCell.dat",GeoIP.GEOIP_STANDARD) | ||
|
||
print gi.org_by_name("yahoo.com") | ||
print gi.org_by_name("www.google.com") | ||
print gi.org_by_addr("24.24.24.24") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/python | ||
|
||
import GeoIP | ||
|
||
#1.4.7 | ||
#Europe/Berlin | ||
#Europe/Berlin | ||
#None | ||
#America/Los_Angeles | ||
#America/New_York | ||
|
||
print GeoIP.lib_version() | ||
print GeoIP.time_zone_by_country_and_region("DE", 'XY') | ||
print GeoIP.time_zone_by_country_and_region("DE", '') | ||
print GeoIP.time_zone_by_country_and_region("US", "") | ||
print GeoIP.time_zone_by_country_and_region("US", "CA") | ||
print GeoIP.time_zone_by_country_and_region("US", "MA") | ||
|