Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50009 > unrolled thread

Geo Location extracted from visitors ip address

Started byΝίκος Gr33k <nikos@superhost.gr>
First post2013-07-05 22:08 +0300
Last post2013-07-05 22:43 +0300
Articles 20 on this page of 38 — 12 participants

Back to article view | Back to comp.lang.python


Contents

  Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 22:08 +0300
    Re: Geo Location extracted from visitors ip address Tim Chase <python.list@tim.thechases.com> - 2013-07-05 14:58 -0500
      Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 02:55 +0300
        Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 02:58 +0300
          Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 03:08 +0300
            Re: Geo Location extracted from visitors ip address Joel Goldstick <joel.goldstick@gmail.com> - 2013-07-05 20:56 -0400
              Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 04:10 +0300
                Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 04:41 +0300
                  Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 11:01 +0300
                    Re: Geo Location extracted from visitors ip address Chris Angelico <rosuav@gmail.com> - 2013-07-06 18:30 +1000
                      Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 11:41 +0300
                        Re: Geo Location extracted from visitors ip address Tim Chase <python.list@tim.thechases.com> - 2013-07-06 06:20 -0500
                          Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 23:14 +0300
                            Re: Geo Location extracted from visitors ip address Tim Chase <python.list@tim.thechases.com> - 2013-07-06 15:32 -0500
                              Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 23:51 +0300
                                Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-07 12:40 +0300
                        Re: Geo Location extracted from visitors ip address Dave Angel <davea@davea.name> - 2013-07-06 07:49 -0400
                        Re: Geo Location extracted from visitors ip address Robert Kern <robert.kern@gmail.com> - 2013-07-06 11:21 +0100
                    Re: Geo Location extracted from visitors ip address Grant Edwards <invalid@invalid.invalid> - 2013-07-08 14:27 +0000
                  Re: Geo Location extracted from visitors ip address Grant Edwards <invalid@invalid.invalid> - 2013-07-08 14:27 +0000
                Re: Geo Location extracted from visitors ip address Joel Goldstick <joel.goldstick@gmail.com> - 2013-07-05 21:31 -0400
                Re: Geo Location extracted from visitors ip address Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-05 22:52 -0400
                  Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 10:10 +0300
                    Re: Geo Location extracted from visitors ip address Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-06 10:43 -0400
                      Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 23:12 +0300
                        Re: Geo Location extracted from visitors ip address Tim Chase <python.list@tim.thechases.com> - 2013-07-06 15:33 -0500
                          Re: Geo Location extracted from visitors ip address Νίκος Gr33k <nikos@superhost.gr> - 2013-07-06 23:49 +0300
                        Re: Geo Location extracted from visitors ip address Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-06 18:36 -0400
    Re: Geo Location extracted from visitors ip address Support by Νίκος <nikos@superhost.gr> - 2013-07-05 22:59 +0300
    Re: Geo Location extracted from visitors ip address Tim Roberts <timr@probo.com> - 2013-07-05 13:44 -0700
      Re: Geo Location extracted from visitors ip address Dave Angel <davea@davea.name> - 2013-07-05 17:18 -0400
      Re: Geo Location extracted from visitors ip address Chris Angelico <rosuav@gmail.com> - 2013-07-06 11:06 +1000
    Re: Geo Location extracted from visitors ip address Tim Chase <python.list@tim.thechases.com> - 2013-07-05 17:21 -0500
    Re: Geo Location extracted from visitors ip address Grant Edwards <invalid@invalid.invalid> - 2013-07-05 22:24 +0000
    [OT] Re: Geo Location extracted from visitors ip address Tony the Tiger <tony@tiger.invalid> - 2013-07-06 13:23 -0500
    Re: Geo Location extracted from visitors ip address Joel Goldstick <joel.goldstick@gmail.com> - 2013-07-05 15:23 -0400
    Re: Geo Location extracted from visitors ip address Jerry Hill <malaclypse2@gmail.com> - 2013-07-05 15:28 -0400
    Re: Geo Location extracted from visitors ip address Support by Νίκος <nikos@superhost.gr> - 2013-07-05 22:43 +0300

Page 1 of 2  [1] 2  Next page →


#50009 — Geo Location extracted from visitors ip address

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-05 22:08 +0300
SubjectGeo Location extracted from visitors ip address
Message-ID<kr75jj$eqv$1@news.grnet.gr>
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?

-- 
What is now proved was at first only imagined!

[toc] | [next] | [standalone]


#50016

FromTim Chase <python.list@tim.thechases.com>
Date2013-07-05 14:58 -0500
Message-ID<mailman.4310.1373054197.3114.python-list@python.org>
In reply to#50009
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/

which you can use to either populate an existing database with
the .CSV data there, or use the binary data blob in concert with the
Python API

https://github.com/maxmind/geoip-api-python  # Python + C
http://pypi.python.org/pypi/pygeoip/         # pure Python

Just be sure to adhere to the licensing terms.

-tkc



[toc] | [prev] | [next] | [standalone]


#50028

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 02:55 +0300
Message-ID<kr7me1$jco$1@news.grnet.gr>
In reply to#50016
Στις 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://pypi.python.org/pypi/pygeoip/         # pure Python

Thank you very much Tim.
i am know tryitn 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!


-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50029

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 02:58 +0300
Message-ID<kr7mjs$jco$2@news.grnet.gr>
In reply to#50028
Στις 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://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?


-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50030

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 03:08 +0300
Message-ID<kr7n56$jco$3@news.grnet.gr>
In reply to#50029
Στις 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://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@nikos [~]# ls -l GeoLiteCity.dat
-rw-r--r-- 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat
root@nikos [~]# chmod +x GeoLiteCity.dat
root@nikos [~]# ls -l GeoLiteCity.dat
-rwxr-xr-x 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat*
root@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)
FileNotFoundError: [Errno 2] No such file or directory: 
'/root/GeoIPCity.dat'
 >>>



-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50033

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-07-05 20:56 -0400
Message-ID<mailman.4319.1373072195.3114.python-list@python.org>
In reply to#50030

[Multipart message — attachments visible in raw view] — view raw

On Fri, Jul 5, 2013 at 8:08 PM, Νίκος Gr33k <nikos@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@nikos [~]# ls -l GeoLiteCity.dat
> -rw-r--r-- 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat
> root@nikos [~]# chmod +x GeoLiteCity.dat
> root@nikos [~]# ls -l GeoLiteCity.dat
> -rwxr-xr-x 1 root root 17633968 Jul  3 02:11 GeoLiteCity.dat*
> root@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

[toc] | [prev] | [next] | [standalone]


#50034

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 04:10 +0300
Message-ID<kr7qq2$vqj$1@news.grnet.gr>
In reply to#50033
Στις 6/7/2013 3:56 πμ, ο/η Joel Goldstick έγραψε:
>
> 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'

My mistake.
Is there a differnce between GeoLiteCity.dat and GeoIPCity.dat

> Aside from that you might have some permission problems since the file
> is owned by root.

But he cgi scripts when running have full access to the server.
No? or they only have the kind of access that their user has also?



> As was also pointed out, you only get information about where your isp
> is located.
Its the best i can get to, since there is no other way to match the 
users city.

Β  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 do you mean by that?

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

I just dont want to store visitor's ip addresses any more, i prefer to 
store its city of origin.


-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50035

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 04:41 +0300
Message-ID<kr7sjn$11u$1@news.grnet.gr>
In reply to#50034
Yes i know iam only storing the ISP's city instead of visitor's homeland 
but this is the closest i can get:

try:
   gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat')
   city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
   host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )
except Exception as e:
   host = repr(e)


Tried it myself and it falsey said that i'am from Europe/Athens (capital 
of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece)

If we can pin-point the uvisitor more accurately plz let me know.



-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50051

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 11:01 +0300
Message-ID<kr8itc$lbs$1@news.grnet.gr>
In reply to#50035
Στις 6/7/2013 4:41 πμ, ο/η Νίκος Gr33k έγραψε:
> Yes i know iam only storing the ISP's city instead of visitor's homeland
> but this is the closest i can get:
>
> try:
>    gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat')
>    city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
>    host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )
> except Exception as e:
>    host = repr(e)
>
>
> Tried it myself and it falsey said that i'am from Europe/Athens (capital
> of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece)
>
> If we can pin-point the uvisitor more accurately plz let me know.

Good morning from Greece,

All my Greece visitors as Dave correctly said have the ISP address which 
here in Greece is Europe/Athens, so i have now way to distinct the 
cities of the visitors.

Is there any way to pinpoint the visitor's exact location?


-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50053

FromChris Angelico <rosuav@gmail.com>
Date2013-07-06 18:30 +1000
Message-ID<mailman.4330.1373099438.3114.python-list@python.org>
In reply to#50051
On Sat, Jul 6, 2013 at 6:01 PM, Νίκος Gr33k <nikos@superhost.gr> wrote:
> Is there any way to pinpoint the visitor's exact location?

Yes. You ask them to fill in a shipping address. They may still lie,
or they may choose to not answer, but that's the best you're going to
achieve without getting a wizard to cast Scrying.

ChrisA

[toc] | [prev] | [next] | [standalone]


#50054

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 11:41 +0300
Message-ID<kr8l8o$ss9$1@news.grnet.gr>
In reply to#50053
Στις 6/7/2013 11:30 πμ, ο/η Chris Angelico έγραψε:
> On Sat, Jul 6, 2013 at 6:01 PM, ����� Gr33k <nikos@superhost.gr> wrote:
>> Is there any way to pinpoint the visitor's exact location?
>
> Yes. You ask them to fill in a shipping address. They may still lie,
> or they may choose to not answer, but that's the best you're going to
> achieve without getting a wizard to cast Scrying.

No, no registration requirements.

you know when i go to maps.google.com its always find my exact city of 
location and not just say Europe/Athens.

and twitter and facebook too both of them pinpoint my _exact_ location.

How are they able to do it? We need the same way.

-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50057

FromTim Chase <python.list@tim.thechases.com>
Date2013-07-06 06:20 -0500
Message-ID<mailman.4333.1373109521.3114.python-list@python.org>
In reply to#50054
On 2013-07-06 11:41, Νίκος Gr33k wrote:
> you know when i go to maps.google.com its always find my exact city
> of location and not just say Europe/Athens.
> 
> and twitter and facebook too both of them pinpoint my _exact_
> location.
> 
> How are they able to do it? We need the same way.

A couple possibilities:

1) using the aforementioned HTML5 location API, your device may be
tattling on where you are.  Are you browsing from a smart-phone or
other device with a GPS built in?

2) at some point in the distant past, you told Google where you are,
and it has dutifully remembered that.  Try using an alternate browser
in a new session (Firefox has the ability to create a new profile;
Chrome/Chromium should have the ability to start up with a virgin
profile; I can't say for Safari or IE) and see if Google suddenly
lacks the ability to locate you

3) Google has a better IP-to-location map database than you have.
You might have to pay real money for such functionality.  Or, you
might have to use a different library, as the IP-to-location database
that I linked you to earlier has both an "IP to Country" and an "IP
to City" database.  Note that this is often wrong or grossly
inaccurate, as mentioned in other threads (geolocation by IP address
often puts me in the nearest major city which is a good 45min drive
away, and if I just visit Google maps with a fresh browser, it just
shows me the state, TX, which is a ~13hr drive across, if done at
65mph the whole way)

-tkc



[toc] | [prev] | [next] | [standalone]


#50083

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 23:14 +0300
Message-ID<kr9tr7$qdu$2@news.grnet.gr>
In reply to#50057
Στις 6/7/2013 2:20 μμ, ο/η Tim Chase έγραψε:
> 1) using the aforementioned HTML5 location API, your device may be
> tattling on where you are.  Are you browsing from a smart-phone or
> other device with a GPS built in?

I'm using my lenovo laptop, by maps.gogole.com, fb and twitter have no 
problem pionpoint my exact location, even postal code.

How do they do it?

Can you be more specific please about using the aforementioned HTML5 
location API ?

Never heard of it. Can it be utilizized via a python cgi script?



-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50086

FromTim Chase <python.list@tim.thechases.com>
Date2013-07-06 15:32 -0500
Message-ID<mailman.4347.1373142638.3114.python-list@python.org>
In reply to#50083
On 2013-07-06 23:14, Νίκος Gr33k wrote:
 Can you be more specific please about using the aforementioned
> HTML5 location API ?

https://www.google.com/search?q=html5+location+api

It's client-side JavaScript.

> Never heard of it. Can it be utilizized via a python cgi script?

Because it's client-side JavaScript, it runs, well, on the client's
browser.  Note that the user may be prompted regarding whether they
want to permit the website to access location information, so this
information may not be available.  If the user permits and JS is
enabled, the client-side JS code can then make AJAX requests (or stash
it in a cookie that gets sent with future requests) to convey the
location information to the server where your Python code is running.

-tkc

[toc] | [prev] | [next] | [standalone]


#50089

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-06 23:51 +0300
Message-ID<kra01a$tvf$2@news.grnet.gr>
In reply to#50086
Στις 6/7/2013 11:32 μμ, ο/η Tim Chase έγραψε:
> Can you be more specific please about using the aforementioned
>> HTML5 location API ?
> https://www.google.com/search?q=html5+location+api
>
> It's client-side JavaScript.


so, i must edit my cgi script and do this:

print '''
<script>
var x=document.getElementById("demo");
function getLocation()
   {
   if (navigator.geolocation)
     {
     navigator.geolocation.getCurrentPosition(showPosition);
     }
   else{x.innerHTML="Geolocation is not supported by this browser.";}
   }
function showPosition(position)
   {
   x.innerHTML="Latitude: " + position.coords.latitude +
   "<br>Longitude: " + position.coords.longitude;
   }
</script>
'''

Will that do the trick?

but then again i want the city to be stored in the city variable.
Somehow the above javascript code mu return me a value that i will the 
store at variable "city".

I don't know how to do that.

-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50100

FromΝίκος Gr33k <nikos@superhost.gr>
Date2013-07-07 12:40 +0300
Message-ID<krbd3a$rc7$1@news.grnet.gr>
In reply to#50089
Στις 6/7/2013 11:51 μμ, ο/η Νίκος Gr33k έγραψε:
> Στις 6/7/2013 11:32 μμ, ο/η Tim Chase έγραψε:
>> Can you be more specific please about using the aforementioned
>>> HTML5 location API ?
>> https://www.google.com/search?q=html5+location+api
>>
>> It's client-side JavaScript.
>
>
> so, i must edit my cgi script and do this:
>
> print '''
> <script>
> var x=document.getElementById("demo");
> function getLocation()
>    {
>    if (navigator.geolocation)
>      {
>      navigator.geolocation.getCurrentPosition(showPosition);
>      }
>    else{x.innerHTML="Geolocation is not supported by this browser.";}
>    }
> function showPosition(position)
>    {
>    x.innerHTML="Latitude: " + position.coords.latitude +
>    "<br>Longitude: " + position.coords.longitude;
>    }
> </script>
> '''
>
> Will that do the trick?
>
> but then again i want the city to be stored in the city variable.
> Somehow the above javascript code mu return me a value that i will the
> store at variable "city".
>
> I don't know how to do that.

I had a reply of another person telling me these:

Google, Facebook, Microsoft, Amazon and most other gigantic companies 
with lots of money track you in several different ways, not just by the 
IP. They compare several categories of tracking to generate a list of 
possible locations for you and then pick the one with the highest 
confidence.

For example, I have an AU phone. If I register with AU Cloud that also 
registers me with Google, and then my AU tower, IP and GPS location all 
get reported to Google. When I login later on a desktop to the same 
GoogleID account, they only have my IP and tracking cookies to look at, 
but they already know to check the latest location of my phone -- and 
whether its turned on/permitting GPS updates right then affects the 
confidence report % of that method of tracking. Recent reservations, 
dated product/service reviews, driving directions, map inquiries, map 
bookmarks/pins, etc. all give some confidence for frequented location 
and movement history each. Any billing relationship you have with them 
will give them another tracking point based on your billing address, and 
they can compare the billing address with frequented GPS locs, past 
shipping information and recent locale-oriented searches. The more 
recent the data and the more points of data match the same location the 
more confidence the potential location has.

...and so on.

Its pretty creepy, actually. Anyway, you can't just do this using IP 
information. To get reliable, live, pinpoint user location data you need 
to do one of:
Convince the user to report/register/pick their location
Convince the user to permit you to track their phone
Get a contract with Google that buys you their best guess at user location
Be like Google and engage in a conspiracy to invade the privacy of 
millions that dwarfs the resources of most intelligence agencies (and 
then sell it to intelligence agencies, just like Google does)


-- 
What is now proved was at first only imagined!

[toc] | [prev] | [next] | [standalone]


#50058

FromDave Angel <davea@davea.name>
Date2013-07-06 07:49 -0400
Message-ID<mailman.4334.1373111366.3114.python-list@python.org>
In reply to#50054
On 07/06/2013 04:41 AM, Νίκος Gr33k wrote:
> Στις 6/7/2013 11:30 πμ, ο/η Chris Angelico έγραψε:
>> On Sat, Jul 6, 2013 at 6:01 PM, ����� Gr33k <nikos@superhost.gr> wrote:
>>> Is there any way to pinpoint the visitor's exact location?
>>
>> Yes. You ask them to fill in a shipping address. They may still lie,
>> or they may choose to not answer, but that's the best you're going to
>> achieve without getting a wizard to cast Scrying.
>
> No, no registration requirements.
>
> you know when i go to maps.google.com its always find my exact city of
> location and not just say Europe/Athens.
>
> and twitter and facebook too both of them pinpoint my _exact_ location.
>
> How are they able to do it? We need the same way.
>

At some point, you entered your address, and it's stored in some 
database in the sky.  You have cookies on your machine which correlate 
to that database.

Chances are you did it for google-maps, and google shared it with their 
search engine and other parts.

As far as I know, each such company has a separate database, but perhaps 
google (for exakmple) has an partner API which facebook uses.

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#50136

FromRobert Kern <robert.kern@gmail.com>
Date2013-07-06 11:21 +0100
Message-ID<mailman.4374.1373275356.3114.python-list@python.org>
In reply to#50054
On 2013-07-06 09:41, Νίκος Gr33k wrote:
> Στις 6/7/2013 11:30 πμ, ο/η Chris Angelico έγραψε:
>> On Sat, Jul 6, 2013 at 6:01 PM, ����� Gr33k <nikos@superhost.gr> wrote:
>>> Is there any way to pinpoint the visitor's exact location?
>>
>> Yes. You ask them to fill in a shipping address. They may still lie,
>> or they may choose to not answer, but that's the best you're going to
>> achieve without getting a wizard to cast Scrying.
>
> No, no registration requirements.
>
> you know when i go to maps.google.com its always find my exact city of location
> and not just say Europe/Athens.
>
> and twitter and facebook too both of them pinpoint my _exact_ location.
>
> How are they able to do it? We need the same way.

They use client-side JavaScript. This is a relatively new API available in most, 
but not all, recent browsers. This information will not be available to your CGI 
script. You will have to generate HTML with the proper JavaScript to get the 
geolocation (if the user allows it) and then send it back to your server through 
a different CGI script (or web application endpoint).

   http://diveintohtml5.info/geolocation.html

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

[toc] | [prev] | [next] | [standalone]


#50157

FromGrant Edwards <invalid@invalid.invalid>
Date2013-07-08 14:27 +0000
Message-ID<krei8o$8td$2@reader2.panix.com>
In reply to#50051
On 2013-07-06, ?????????? Gr33k <nikos@superhost.gr> wrote:
> ???????? 6/7/2013 4:41 ????, ??/?? ?????????? Gr33k ????????????:
>> Yes i know iam only storing the ISP's city instead of visitor's homeland
>> but this is the closest i can get:
>>
>> try:
>>    gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat')
>>    city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
>>    host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )
>> except Exception as e:
>>    host = repr(e)
>>
>>
>> Tried it myself and it falsey said that i'am from Europe/Athens (capital
>> of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece)
>>
>> If we can pin-point the uvisitor more accurately plz let me know.
>
> Good morning from Greece,
>
> All my Greece visitors as Dave correctly said have the ISP address which 
> here in Greece is Europe/Athens, so i have now way to distinct the 
> cities of the visitors.
>
> Is there any way to pinpoint the visitor's exact location?

No.

-- 
Grant Edwards               grant.b.edwards        Yow! Does someone from
                                  at               PEORIA have a SHORTER
                              gmail.com            ATTENTION span than me?

[toc] | [prev] | [next] | [standalone]


#50156

FromGrant Edwards <invalid@invalid.invalid>
Date2013-07-08 14:27 +0000
Message-ID<krei89$8td$1@reader2.panix.com>
In reply to#50035
On 2013-07-06, ?????????? Gr33k <nikos@superhost.gr> wrote:
> Yes i know iam only storing the ISP's city instead of visitor's homeland 
> but this is the closest i can get:
>
> try:
>    gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat')
>    city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
>    host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )
> except Exception as e:
>    host = repr(e)
>
>
> Tried it myself and it falsey said that i'am from Europe/Athens (capital 
> of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece)
>
> If we can pin-point the uvisitor more accurately plz let me know.

For the Nth time: you can't.

-- 
Grant Edwards               grant.b.edwards        Yow! HOORAY, Ronald!!
                                  at               Now YOU can marry LINDA
                              gmail.com            RONSTADT too!!

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web