4
Python GeoIP (python-geoip) cities tutorial
Using geolocation is something that people are doing a lot lately. You may have noticed twitter.com in FireFox showing a little bar at the top asking if it’s alright to share your location. This is so that when you tweet you can have your location show up there. That way you can keep track of where you tweet from. There are many uses for this kind of information and these days there’s a lot of free things out there to help you get started with your geolocation project.
Installing GeoIP
Requirements/Dependancies:
- Python 2.4+
- python-geoip
- libc6
- libgeoip1
More on dependencies here http://ns2.canonical.com/es/karmic/python-geoip. But don’t worry about these since most of them get installed by the package anyway.
A couple of basic principles before we get started.
- Geolocation is gathered from an IP address.
- There has to be a database that connects the IP address to a geographical location
I’m going to be using Python here because frankly it’s powerful, easy and has awesome libraries for geolocation. Which brings me to the GeoIP library! I’m using Ubuntu 9.10 so most of these libraries will just take an apt-get to install.
Then you can install python-geoip with
sudo apt-get install python-geoip
Or you can get the source from http://geolite.maxmind.com/download/geoip/api/python/
Now that you have this installed you can test it with the following code put in the python terminal.
>>> import GeoIP
>>> gi = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE)
>>> print gi.country_code_by_addr("203.195.93.0")
I got that from MaxMind’s tutorial http://www.maxmind.com/app/python. At this point you have the ability to track IPs down to the country level. What you probably really want is to go down to the city level.
Geolocation – Cities
If you call some of the other functions on the GeoIP class like record_by_addr() you’lld get an error like this
“Invalid database type GeoIP Country Edition, expected GeoIP City Edition, Rev 1″
7
How many users on Twitter?
Twitter has been pretty strict in making sure that the public is not aware of how many users they have and this is probably for good reason. I really think the amount of hype that Twitter has had is not justified. So then, the question I set out to answer is quite simple and that question is, how many twitter accounts are there?
So from that point there is another question that must be asked and that is, who would know the information I’m looking for, other than Twitter?
So first I google’d around a little and I found this article on TechCrunch which had some excellent information on the subject. Information about how user ID numbers on Twitter do not reflect the number of users that are on Twitter.
25
Balthasar Week 2 Report
In a post a couple of weeks ago, I mentioned setting up a new GoogleCode project. I’m happy to say that Balthasar is coming along nicely. For details on what Balthasar is and how to get involved, read on.
22
Episode #5 – Tekken thumb to the French police
Sorry we’re so late in getting this out. Hopefully, we can get on a regular schedule for putting these podcasts out and maybe some good posts too.
Keep watching and feel free to comment or give suggestions!
- Topics
- “Tekken Thumb”
- Quad-core vs. Dual-core
- Chainlove.com
- The french police adopt ubuntu arstechnica.com
- More talk of communications between linux distributions
- We got Linked!
- “fizzbin” hanselman.com
- deathswitch lifehacker.com
- spokenword.org
- Twitter uses amazon S3 to host it’s images
9
The Future of Google
For those of you who want to argue that Google is doing just fine (ahem), I refer you to some new articles on the subject. Google may not be in the trouble I originally blogged about, but this article generalizes the difficulties it faces in terms of past internet giants like AOL, and this article reiterates the Twitter Threat discussed in the first article. As I recall, somebody and somebody else have been writing Ubiquity scripts to let them search specific sites from any webpage. Dare I say it, but I think people are finding alternatives to searching with the Old Ways.
Tom’s remarks about One Login to Rule Them All, however, is still valid. I won’t take that away from him.


