The other day I wondered what kind of keywords that websites had been using but I wanted to see them in the context of a search, just like Google's search results. I need a mini-app!
The gist of the mini-app is this.
You key in the query and keywordr will do a search on Google for your query. It will scan through the list of returned results and check each URL in the results for a list of keywords.
Using Sinatra, I was able to put together an application the does this. You can see the latest version of it here.
I did initially want to return the keyword metatag for each website, but I found that Peter Cooper's pismo gem does a keyword search of any URL you pass to it.
What I learned
- Searching a page using Nokigiri's CSS selector - This seems a much easier way of searching a page. I had only used XPath's previously.
- Embedded tests in a Sinatra file - I'm trying to keep my mini-apps in single files, but I wanted to use TDD as well. This was a good place to learn how to embed tests with a single file Sinatra app.
- Some basics of Haml - I tried Haml before but never took to it. Too keep my mini-apps small, I wanted use a more concise and readable syntax for layouts and views. Back to Haml.
What next
- A nice way paging through the next set of results would be nice.
- Being able to get more results on the page would be good.
- I don't like the way I run my tests for the mini-app, but it works for the moment.
I've neglected my little incubator project for sometime, but in the future I'm hoping to add a mini-app every month.