當我查詢GeoLite2-City.mmdb數據庫與ip ='104.6.30.56'(來自Python)時,我得到錯誤的位置。他們的演示網站返回此IP的良好數據(https://www.maxmind.com/en/geoip-demo)。MaxMind GeoLite2返回錯誤的位置
In [33]: import geoip2.database
In [34]: reader = geoip2.database.Reader('.../GeoLite2-City.mmdb')
In [35]: reader.city('104.6.30.56').city # should be Santa Rosa, Ca
Out[35]: geoip2.records.City(geoname_id=None, confidence=None, _locales=['en'], names={})
In [36]: reader.city('104.6.30.56').location # should be ~(38, -122)
Out[36]: geoip2.records.Location(postal_confidence=None, average_income=None, accuracy_radius=None, time_zone=None, longitude=-97.0, metro_code=None, population_density=None, postal_code=None, latitude=38.0)
In [37]: reader.city('173.194.116.131').city # works fine for Google
Out[37]: geoip2.records.City(geoname_id=5375480, confidence=None, _locales=['en'], names={u'ru': u'\u041c\u0430\u0443\u043d\u0442\u0438\u043d-\u0412\u044c\u044e', u'fr': u'Mountain View', u'en': u'Mountain View', u'de': u'Mountain View', u'zh-CN': u'\u8292\u5ef7\u7ef4\u5c24', u'ja': u'\u30de\u30a6\u30f3\u30c6\u30f3\u30d3\u30e5\u30fc'})
版本:
In [39]: reader.metadata()
Out[39]: maxminddb.reader.Metadata(binary_format_major_version=2, description={u'en': u'GeoLite2 City database'}, record_size=28, database_type=u'GeoLite2-City', languages=[u'de', u'en', u'es', u'fr', u'ja', u'pt-BR', u'ru', u'zh-CN'], build_epoch=1438796457, ip_version=6, node_count=3199926, binary_format_minor_version=0)
In [40]: geoip2.__version__
Out[40]: '2.2.0'
這是因爲我使用的是精簡版的版本?
這可能是由於商業和精簡版。你可以考慮其他數據庫。例如,http://lite.ip2location.com上的IP2LITE LITE按預期顯示Santa Rosa爲104.6.30.56。 –