GeoIP in PYTHON














































GeoIP in PYTHON



 

                                                          GEOIP IN PYTHON 




 What is IP ?

 IP address stands for internet protocol address . it is a numerical label assigned to each device .

GeoIp  is a library  it can be used access to Geoip databases.

             it refers to the method of locating a computer terminal's geographic location by identifying that terminal's IP address

 MaxMind The MaxMind Database  file format is a database format that maps IPv4 and IPv6 addresses to data  using an efficient binary search tree . It can be also Used to online fraud detection.
 

Requirements:
                        Python 2.5 or 3.4 version  onwards
                        GeoIP C Library 1.4.8 or greater


Installation:
                   pip install python-geoip

 If you  want the free MaxMind Geolite2 database then

                            pip install python-geoip-geolite2

Code:


>>> from geoip import geolite2
>>> match = geolite2.lookup('18.0.0.1')
>>> match is not None
True
>>> match.country
'canada'
>>> match.continent
'NA'
>>> match.timezone
'
Eastern Daylight Time'
>>> match.subdivisions
frozenset(['CA'])
>>> from geoip import open_database
>>> db = open_database('path/to/my.mmdb')


Application programming interface (API):

1.geoip.open_database(filename):
       it is used to open a given database

2.class geoip.Database:
            it is used to Provides access to a GeoIP database
3. close():
          it is used to close database.The whole object can also be used as a context manager. Databases that are packaged up  do not need to be closed.

4.get_info()

Returns an info object about the database. This can be used to check for the build date of the database or what provides the GeoIP data.

5. get_metadata():
      Return the metadata dictionary of the loaded database. This dictionary is specific to the database provider.

6. class geoip.IPInfo(ipdata):
       Provides information about the located IP as returned by Database.lookup().
                   


Uses:

          The most prevalent application of GeoIP involves geo-targeting, or determining a computer's location in order to tailor content specifically for that location. 
           Geo-targeting is most often used for targeted advertising, statistical research, spam prevention, and for restricting access based on location.
            The way the IP-based geolocation works is simply by checking which IP range is used by which area, using an IP-to-location database.Once they connect to your site you already know their IP address,so just by using the Users Insights Geolocation module, you can find their location. %




More Articles of Bhanu Prakash Reddy M:

Name Views Likes
Python - Generic output formatting 360 11
Python - Standard Encodings in Binary Data service 330 29
Python - Stream Encoding and Decoding 379 16
Python - Stateless Encoding and Decoding in Binary data service 355 22
Python Binary Data Service Error Handlers 353 51
Python - Binary Data Services - 2 373 33
Python Binary Data Services 389 92
Python - Dijkstras shortest path algorithm 465 24
Python - Prims minimum spanning tree 403 22
Python - Cookies in CGI 346 23
Python CGI Environment Variables 377 20
CGI Programming-2 389 49
Python - CGI Programming 385 39
Python The Knights tour problem 537 47
Python User-defined Exceptions 626 57
Python Concrete exceptions part-2 630 28
Python Concrete exceptions 617 12
Python Built-in Exceptions 631 13
Python Program In-order traversal of a tree without using recursion 645 28
Python Program pre-order traversal of a tree without using recursion 639 29
Python Program post-order traversal of a tree without using recursion 652 22
Python Cryptographic Generating tokens 709 13
Python Cryptographic Secure hashes and message digests 697 65
Python Cryptographic Introduction 734 11
Python Generate secure random numbers 733 41
Python Random module --2 735 18
Python Random Module 736 22
Python IP Geolocation 754 13
Python Data Changes to GeoIP Legacy 749 10
Python Geoip Enriching MMDB files 758 16
Python The Easy Way to Use MaxMind GeoIP 795 25
Python Types of Anonymous IPs and How They Affect Your Business 774 19
Python GeoIP2 Databases with HAProxy Enterprise 773 25
Python Geoip Maxmind 798 34
Python Geoip2 Configuring geolocation 810 24
Python Geolocation with GeoIP2 807 61
Python GeoIP2 JavaScript Client API 814 33
Python GeoIP2 Precision Services 816 24
Python Geoip2 Modules 880 34
Python Geoip Database Reader Exceptions 880 30
Python MaxMind GeoIP2 863 33
Python program for panagram 891 30
Python program for Smallest Palindrome 916 13
Python program for Friends on Facebook 937 21
Python Program for Choosing Balls 896 17
Python program for frequency is a function that takes as input a list of integers and returns a pair of the form (minfreqlist,maxfreqlist) 928 42
Python Program for Rotate Matrix Elements 895 11
GeoIP -- Flask. 911 15
Geoip-IP geolocation information in Python. 908 15
GeoIP - MaxMind GeoIP2 API 918 21
Python Program 919 20
Python program for Domino Solitaire 924 22
Python-- Programs 910 14
Plotting Series in Python 930 24
GeoIP in PYTHON 964 23

Comments