你好,我刚开始编写代码,我想为一个个人项目构建一些东西,我偶然发现了MaxMind的ip查找api。他们的付费版本,即GeoIp2,对我来说有点贵,但他们确实有一个免费版本,即GeoLite2。但是他们的文档没有任何如何导入的例子。
GeoIp2的Python文档
>>> import geoip2.webservice
>>>
>>> # This creates a Client object that can be reused across requests.
>>> # Replace "42" with your account ID and "license_key" with your license
>>> # key. Set the "host" keyword argument to "geolite.info" to use the
>>> # GeoLite2 web service instead of GeoIP2 Precision.
>>> with geoip2.webservice.Client(42, 'license_key') as client:
>>>
>>> # Replace "city" with the method corresponding to the web service
>>> # that you are using, i.e., "country", "city", or "insights". Please
>>> # note that Insights is not supported by the GeoLite2 web service.
>>> response = client.city('203.0.113.0')在他们提到的将主机更改为使用GeoLite2的评论中,我不明白我需要更改什么。我从我身边尝试了一切可能的事情,但都失败了。如果有人能帮我做这件事-
发布于 2022-02-07 13:00:15
如果你省略了“主机”,它就会起作用。所以只有.Client(ID,License_key,"geolite.info")
https://stackoverflow.com/questions/68285636
复制相似问题