What python libraries can tell me approximate location and time zone given an IP address?

后端 未结 13 722
借酒劲吻你
借酒劲吻你 2020-11-28 03:31

Looking to implement better geo-location with Python.

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 04:11

    Hostip.info is an open-source project with the goal to build/maintain a database mapping IP addresses to cities. Their about page explains the data sources relied on to populate this database.

    Using HostIP, there are two ways to get location data from an IP address:

    They also have a well-designed and easy-to-use RESTFUL API: just pass in your ip address after the i***p=*** in the GET request string):

    import urllib
    
    response = urllib.urlopen('http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true').read()
    
    print(response)
    

    Second, the Project Website also makes its complete database available for download.

提交回复
热议问题