ipfree (version 1.3, 2005-04-14) | index /Users/ping/dev/python/ipfree.py |
Look up the country for a given IP address.
>>> import ipfree
>>> ipfree.lookup('129.97.128.15')
('CA', 'Canada')
>>> ipfree.lookup('194.109.137.226')
('NL', 'Netherlands')
>>>
This module provides a single function, lookup(ipaddr), that returns the
two-letter country code and country name for an IP address given as a
string of four period-separated decimal numbers. The database in this
module is derived from the free database in the Perl module Geo::IPfree.
Functions | ||
|
Data | ||
__author__ = 'Ka-Ping Yee' __date__ = '2005-04-14' __version__ = '$Revision: 1.3 $' addrmap = [('000.000.000.000', 'US'), ('001.000.000.000', 'IN'), ('002.000.000.000', 'US'), ('004.018.066.000', 'MX'), ('004.018.068.000', 'US'), ('004.020.070.000', 'FR'), ('004.020.071.000', 'US'), ('004.022.197.000', 'CA'), ('004.022.198.000', 'US'), ('004.023.003.000', 'PH'), ('004.023.004.000', 'US'), ('009.020.000.000', 'GB'), ('009.020.128.000', 'US'), ('010.000.000.000', 'I0'), ('011.000.000.000', 'US'), ('012.008.184.000', 'PR'), ('012.008.185.000', 'US'), ('012.008.188.000', 'EC'), ('012.008.189.000', 'JM'), ('012.008.190.000', 'EC'), ...] countries = {'--': 'unknown', 'A1': 'anonymous proxy', 'A2': 'satellite provider', 'AD': 'Andorra', 'AE': 'United Arab Emirates', 'AF': 'Afghanistan', 'AG': 'Antigua and Barbuda', 'AI': 'Anguilla', 'AL': 'Albania', 'AM': 'Armenia', ...} |
Author | ||
Ka-Ping Yee |