views:

99

answers:

2

Curious as to how to approach this same problem using ruby / rails - http://stackoverflow.com/questions/399332/fastest-way-to-retrieve-a-title-in-php

Is there a plugin or gem that anyone recommends? cheers!

+1  A: 

This would probably be pretty easy with Nokogiri.

Andy Gaskell
nice suggestion!
drpepper
+2  A: 

In the same spirit as the PHP tread, lets do this with no special gems:

require 'open-uri'
open('http://www.google.com').read.match(/<title>(.*?)<\/title>/)[1]

..and out comes Google

Thorbjørn Hermansen
+1 for a solution that works. This wouldn't be the fastest though, `Nokogiri` and `Hpricot` (sigh!) are a lot faster.
Swanand