Thursday, January 27, 2005

trackback test
test of trackback in Radio



Python Challenge: Top 5 list
This morning I had the rare opportunity to work in my favorite programming language, Python. The script I was creating was simple, fun to do, and I did it in less lines of code than I expected. So, great experience.

Tonight I was thinking about learning Python, learning new modules, and such. I thought about what a great learning tool little, periodic Python Challenges would be.

Background

Sometimes I know exactly (or almost exactly) what I want on Google, but getting there is a pain. Switch to my browser, go to the Google tool on the toolbar, enter my string, hit return, and wade through Google results. Too much work when I'm going to enter a very specific string where one of the top 5 links will be the one I want.

In Depth

I want to have a command-line tool where I enter the search string as an argument, and it returns the following for the first 5 results:

  1. Title of the found site
  2. Url of the found site
  3. 10 word excerpt from the summary

Bonus Points

Bonus points will be awarded on basis of extra features -- for example, maybe entering a result number (1-5) would take me to the website in question (in my favorite browser). Perhaps I can get additional text from the excerpt, or find similar pages. Additional GUI (Mac OS X Service, anyone?) also gets major points.

Hints

Google is your friend. A module exists that will make this script easy (and not a grepping through results from curl nightmare).

Leave a comment on the blog with the location of your script, or ping me with a trackback.

In addition, suggesting Python Challenges would be very welcome!