Geo Location extracted from visitors ip address

Joel Goldstick joel.goldstick at gmail.com
Fri Jul 5 20:56:25 EDT 2013


On Fri, Jul 5, 2013 at 8:08 PM, Νίκος Gr33k <nikos at superhost.gr> wrote:

> Στις 6/7/2013 2:58 πμ, ο/η Νίκος Gr33k έγραψε:
>
>  Στις 6/7/2013 2:55 πμ, ο/η Νίκος Gr33k έγραψε:
>>
>>> Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε:
>>>
>>>> On 2013-07-05 22:08, Νίκος Gr33k wrote:
>>>>
>>>>> Is there a way to extract out of some environmental variable the
>>>>> Geo location of the user being the city the user visits out website
>>>>> from?
>>>>>
>>>>> Perhaps by utilizing his originated ip address?
>>>>>
>>>>
>>>> Yep.  You can get an 11MB database (17MB uncompressed)
>>>>
>>>> http://dev.maxmind.com/geoip/**legacy/downloadable/<http://dev.maxmind.com/geoip/legacy/downloadable/>
>>>>
>>>
>>>  http://pypi.python.org/pypi/**pygeoip/<http://pypi.python.org/pypi/pygeoip/>        # pure Python
>>>>
>>>
>>> Thank you very much Tim.
>>> i am know trying to use it as:
>>>
>>> import pygeoip
>>>
>>> try:
>>>    gic = pygeoip.GeoIP('/root/**GeoIPCity.dat')
>>>    host = gic.time_zone_by_addr( os.environ['HTTP_CF_**CONNECTING_IP'] )
>>> except Exception as e:
>>>    host = repr(e)
>>>
>>> lets hope it will work!
>>>
>>
>> Just my luck again,
>>
>> PermissionError(13, 'Άρνηση πρόσβασης')
>>
>> Άρνηση πρόσβασης = Access Denied
>>
>> Why would that happen?
>>
>
> root at nikos [~]# ls -l GeoLiteCity.dat
> -rw-r--r-- 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat
> root at nikos [~]# chmod +x GeoLiteCity.dat
> root at nikos [~]# ls -l GeoLiteCity.dat
> -rwxr-xr-x 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat*
> root at nikos [~]# python
> Python 3.3.2 (default, Jun  3 2013, 16:18:05)
> [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pygeoip
>
> >>> gic = pygeoip.GeoIP('/root/**GeoIPCity.dat')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python3.3/**site-packages/pygeoip-0.2.6-**
> py3.3.egg/pygeoip/__init__.py"**, line 110, in __init__
>     self._filehandle = codecs.open(filename, 'rb', ENCODING)
>   File "/usr/local/lib/python3.3/**codecs.py", line 884, in open
>     file = builtins.open(filename, mode, buffering)
>

Your code is not finding /root/GeoIPCity.dat because your directory has
this file: GeoLiteCity.dat

> FileNotFoundError: [Errno 2] No such file or directory:
> '/root/GeoIPCity.dat'


Aside from that you might have some permission problems since the file is
owned by root.  You should go back to old threads where this issue was
explained.

As was also pointed out, you only get information about where your isp is
located.  Phones and tablets find location from triangulating cell towers.
I don't think that laptops have that capability, and desktops probably even
less likely.

What is the purpose that you wish to serve.  I don't think you've thought
this through.

>
> >>>
>
>
>
> --
> What is now proved was at first only imagined!
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130705/653bb605/attachment.html>


More information about the Python-list mailing list