home :: hacks :: recent-google.txt

RSS 0.91 feeds Subscribe and save over 75% off newsstand price!

car - 9
games - 2
hacks - 21
  flac - 4
  photo - 5
  slim - 3
journal - 153
misc - 5
news - 9
pomona - 2
rants - 6

For the biographers:

2005 - 2006 - 2007 - 2008 - 2009

Now playing

Décollage (Cristobal Paz & Leo di Giusto remix)
from Remixed by Bajofondo
at Monday, December 14, 2009 12:51 AM

How this works

Hot Live Webcam

Yes, really.

Recently from Google

from Chicago IL, searching for michael dickerson attempted murder

from Boston MA, searching for flac cuesheet how-to

from Claremont CA, searching for Micheal Dickerson Emergency Response at Google

How this works

Contact me

mikey@singingtree.com
4171622
mdickers47
mike.dickerson@pomona.edu
pomonamikey
wii number7808 7239 7724 0213
blackberry pin204db8e4

On Notice

  • The sun
  • Librarians
  • Blue
  • Purple
  • David Gray
  • Whirlpool
  • Taco Bell

As seen on The Colbert Report.

This site does not represent my employer.

May look horrible in Internet Explorer.

blosxom logo   Creative Commons License

gotta
knock
a
little
harder

obstrepero.us banner
obstrepero.us mistakes you can learn from

Displaying recent Google visitors in Blosxom

filed under: /hacks

Only a couple weeks after starting this blog, I was surprised to discover that I am already getting a couple dozen visitors from Google per day. It's interesting to see what they were searching for, since it makes me feel like I have an audience, so I thought I'd display them in the sidebar over there. I did this with two pieces:

recent_google Blosxom plugin (Perl, 1kb)
update_recent_google script that keeps the plugin state up to date (3kb)

The Blosxom plugin is trivial and documents itself. It just provides a variable $recent_google::recent that gets expanded to either the contents of a state file (when doing dynamic rendering), or else an SSI command to do the same (when doing static rendering). This is a trick I have used on some other plugins, in order to let me render the whole blog statically to .shtml files, which can then use SSI to still pull in small dynamic pieces like the Now Playing box, or in this case, the recent Google searches.

Most of the work is done by the update_recent_google.pl script, which I run from cron once an hour. It reads the last 1000 lines of your Apache log file (to which you must have access), and creates a little bit of HTML that goes in the state file to be included in the blog page.

Nothing that simple could possibly be fun to hack of course, so I had to go one better and find an IP geolocation service that would make it possible to display where the visitor came from as well. There are several companies that sell this information, but usually for $300-400 for a year's subscription and unlimited usage, which is vastly overkill for my goofy 5 or 10 lookups a day. But fortunately, I found one place, Maxmind, that sells a "Web service" version that lets you do 50,000 lookups using a simple http interface for $20. Perfect for my goofy Google plugin. If you want your goofy Google plugin to do the same, you just need to get your own Maxmind license key and put it in the script where it says, "Put your license key here". Otherwise, it should be hardly any more difficult to hack out the Maxmind stuff and make the output look like whatever you want.

So, Google visitors, know that I have paid US $0.0004 to find out where you come from, just because I care about blogging the best blog experience for you that I can. The least you could do is click one of my Amazon links and buy something.

01 Dec 2005 13:19 PT - persistent link - trackback - 0 comments

Copyright © 2005-06 Michael A. Dickerson