pylocation

Python Wrapper Library for Geolocating IP Addresses
Download

pylocation Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Mark Costello
  • Publisher web site:
  • https://github.com/mcos/

pylocation Tags


pylocation Description

pylocation is a Python module to wrap the IP address geolocation service from hostip.info.InstallationInstall from PyPI using pip install pylocationUsagefrom pylocation import PyLocation# Initializing without specifying an IP Address gives us the IP information# from the machine using this modulepyloc = PyLocation()# Same as above, but includes the GPS Coordinatespyloc = PyLocation(position=True)# Initializing with an IP addresspyloc = PyLocation(ip='8.8.8.8')# Same as above, but includes the GPS Coordinatespyloc = PyLocation(ip='8.8.8.8', position=True)# Outputspyloc.text # Returns the information as a unicode stringpyloc.jsontext # Returns the information as a JSON stringpyloc.json # Returns the information as JSON parsed to a dictionarypyloc.xmltext # Returns the information as an xml stringpyloc.xml # Returns the information as an XML Element Tree"""The following returns the information as a python object"""pylocinfo = pyloc.infoprint pylocinfo.ip # '8.8.8.8'print pylocinfo.city # 'Mountain View, CA'print pylocinfo.country_name # 'UNITED STATES'print pylocinfo.country_code # 'US'print pylocinfo.latitude # 37.402print pylocinfo.longitude # -122.078"""If you're getting the info for multiple IP addresses, you don't need tocreate multiple PyLocation objects"""pyloc = PyLocation()pyloc.json # Returns the JSON representation of the geolocation info for the IP of the host machinepyloc.ip = '8.8.8.8' # Change the IP to 8.8.8.8pyloc.position = True # Include the GPS Coordinatespyloc.json # Returns the JSON representation of geolocation info for IP 8.8.8.8Product's homepage


pylocation Related Software