Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > GeoIP2 for retrieving city and region ?

Reply
Thread Tools

GeoIP2 for retrieving city and region ?

 
 
Νικόλας
Guest
Posts: n/a
 
      07-12-2013
Hello, iam still looking for a way to identify the city of my website
visitors.

The closet i have gone is to come up with the visitor's ISP city:

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


But today i was searching again for this and found out about geoip2,
maybe that would help more.


>>> import geoip2

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'geoip2'


>>> client = geoip2.webservices.Client(42, 'abcdef123456')
>>> omni = client.omni('24.24.24.24')
>>> country = omni.country
>>> print(country.iso_code)



I cant even import the module even though my 'pip install geopip2' was
successful

There is definately i way to identify the users location based solely on
its ip address as this site does it: http://www.geoiptool.com/

Google, MS, facebook and twitter are not the only ones that can do it?

Perhaps this is being done by giving longitude and latitude?
--
What is now proved was at first only imagined!
 
Reply With Quote
 
 
 
 
Dave Angel
Guest
Posts: n/a
 
      07-12-2013
On 07/12/2013 10:18 AM, Νικόλας wrote:
> Hello, iam still looking for a way to identify the city of my website
> visitors.
>

<SNIP>
>
>
> I cant even import the module even though my 'pip install geopip2' wa
> successful


Either it wasn't successful, or it's not the package you thought. There
are lots of things you might have downloaded, but since you give no
details...


>
> There is definately i way to identify the users location based solely on
> its ip address as this site does it: http://www.geoiptool.com/
>


Sure, and as long as you don't mind it being 1000 miles off, you too can
claim to do it too. When I go to that site, the little pin is in
Kansas, which is 1100 miles from where I live on the east coast of the US.


> Google, MS, facebook and twitter are not the only ones that can do it?
>
> Perhaps this is being done by giving longitude and latitude?


Or by reading the mind of the programmer.

I suggest you read that geoiptool site, in particular the page

http://www.geoiptool.com/en/ip_info/

There is some misinformation, but notice carefully the part about
dynamic IP addresses. Probably 99% of the individual users on the web
(the ones using a browser) have dynamic IP addresses. The fixed ones
are needed by servers, and especially for DNS use, where the name lookup
wants to be stable for relatively log periods of time.

--
DaveA

 
Reply With Quote
 
 
 
 
Νικόλας
Guest
Posts: n/a
 
      07-12-2013
Στις 12/7/2013 6:32 μμ, ο/η Dave Angel *γραψε:
>
> I suggest you read that geoiptool site, in particular the page
>
> http://www.geoiptool.com/en/ip_info/
>
> There is some misinformation, but notice carefully the part about
> dynamic IP addresses. Probably 99% of the individual users on the web
> (the ones using a browser) have dynamic IP addresses. The fixed ones
> are needed by servers, and especially for DNS use, where the name lookup
> wants to be stable for relatively log periods of time.



I did, for me it gives exact city location and not the ISP's city location.

I dont know whay for you ti just says Kansas, it shoudln't, since it
susing longitute and latitude, it should have been accurate.

--
What is now proved was at first only imagined!
 
Reply With Quote
 
Νικόλας
Guest
Posts: n/a
 
      07-12-2013

I know i have asked before but hwta i get is ISP city not visitors
precise city.

GeoLiteCity.dat isnt accurate that's why it comes for free.
i must somehow get access to GeoIPCity.dat which is the full version.

And of course it can be done, i dont want to believe that it cant.

When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
_exact_ city of living, not the ISP's.
It did not even ask me to allow a geop ip javascript to run it present
sit instantly.

So, it certainly is possible if only one can find the correct database
to use.

So, my question now is, if there is some way we can get an accurate Geo
City database.

--
What is now proved was at first only imagined!
 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      07-12-2013
On 2013-07-12, ?????????????? <(E-Mail Removed)> wrote:

> I know i have asked before but hwta i get is ISP city not visitors
> precise city.


You can't reliably do that.

> GeoLiteCity.dat isnt accurate that's why it comes for free. i must
> somehow get access to GeoIPCity.dat which is the full version.
>
> And of course it can be done, i dont want to believe that it cant.


Believe what you want.

> When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
> _exact_ city of living, not the ISP's. It did not even ask me to
> allow a geop ip javascript to run it present sit instantly.


So you've reached your conclusion on a sample size of one?

--
Grant Edwards grant.b.edwards Yow! I'm encased in the
at lining of a pure pork
gmail.com sausage!!
 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      07-12-2013
On Sat, Jul 13, 2013 at 2:38 AM, Grant Edwards <(E-Mail Removed)> wrote:
> On 2013-07-12, ?????????????? <(E-Mail Removed)> wrote:
>> When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
>> _exact_ city of living, not the ISP's. It did not even ask me to
>> allow a geop ip javascript to run it present sit instantly.

>
> So you've reached your conclusion on a sample size of one?


This is Nikos. He doesn't read responses properly, doesn't do his
research, and has (by his own admission) an iron head that doesn't let
information cross it lightly. Yes, he reached his conclusion on a
sample size of one.

Oh, and just for laughs, I tried a few of my recent mobile IP
addresses in the GeoIP lookup. All of them quoted Melbourne someplace,
some in the CBD and some out in the suburbs, but all vastly wrong, and
places I haven't been. But I'd never expect it to be accurate on
those.

ChrisA
 
Reply With Quote
 
Ian Kelly
Guest
Posts: n/a
 
      07-12-2013
On Fri, Jul 12, 2013 at 10:32 AM, <(E-Mail Removed)> wrote:
>
> I know i have asked before but hwta i get is ISP city not visitors precise
> city.
>
> GeoLiteCity.dat isnt accurate that's why it comes for free.
> i must somehow get access to GeoIPCity.dat which is the full version.
>
> And of course it can be done, i dont want to believe that it cant.
>
> When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my _exact_
> city of living, not the ISP's.
> It did not even ask me to allow a geop ip javascript to run it present sit
> instantly.


Try this:

1) Go to http://incloak.com (or any other free web proxy site).
2) Paste in the URL http://www.geoiptool.com and press Enter
3) See where it thinks you are now.

When I tried it, it placed me on the wrong side of the Atlantic Ocean.
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      07-12-2013
On 7/12/2013 1:19 PM, Ian Kelly wrote:

> Try this:
>
> 1) Go to http://incloak.com (or any other free web proxy site).
> 2) Paste in the URL http://www.geoiptool.com and press Enter
> 3) See where it thinks you are now.
>
> When I tried it, it placed me on the wrong side of the Atlantic Ocean.


Me to. Thanks for the link.

--
Terry Jan Reedy

 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      07-12-2013
On 12/07/2013 17:32, Νικόλας wrote:
>
> I know i have asked before but hwta i get is ISP city not visitors
> precise city.
>
> GeoLiteCity.dat isnt accurate that's why it comes for free.
> i must somehow get access to GeoIPCity.dat which is the full version.
>
> And of course it can be done, i dont want to believe that it cant.
>
> When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
> _exact_ city of living, not the ISP's.


Have you considered that your ISP might be in the same city as you?

According to geoiptool, my ISP is near Leeds, UK, but the important
point is that _I'm not_.

> It did not even ask me to allow a geop ip javascript to run it present
> sit instantly.
>
> So, it certainly is possible if only one can find the correct database
> to use.
>
> So, my question now is, if there is some way we can get an accurate Geo
> City database.
>


 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      07-12-2013
On 07/12/2013 10:32 AM, Νικόλας wrote:
> So, my question now is, if there is some way we can get an accurate Geo
> City database.


As has been said pretty much by every other poster, there is no way to
do get an accurate location database. Period.

The databases that do exist were built by hand, and also guessed at
based on routing information. The best you can really do is region, or
country, and even that fails sometimes.

If you want to know a visitor's city you should ask them using the new
browser location apis available to javascript.

http://diveintohtml5.info/geolocation.html

Since IPs can be dynamic, sometimes even assigned across a region,
there's no way to accurately map ip addresses to a city with the
reliability that you seem to want. Google is pretty accurate because
they've spent a lot of time building up their own database, and also
convincing users to reveal their locations to them. Unless you do the
same thing, you have to just get by with what others have provided for you.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Region 0 players and Region 1 Discs Eric DVD Video 3 04-27-2004 12:11 AM
IP Address Geographyc Resolution ( city or region ) Bubu ASP General 0 04-25-2004 02:37 PM
New Region 1 and Region 2 DVD's Bos DVD Video 2 04-24-2004 04:49 PM
Kill Bill Vol.1 R1/R2 DVD and More New Region 1/Region 2 DVD's Bos DVD Video 0 01-18-2004 09:58 AM
MCPs per Region/City eb24 MCAD 1 01-13-2004 09:51 PM



Advertisments