0

Curious as to how to approach this same problem using ruby / rails - Fastest way to retrieve a <title> in PHP

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

Community
  • 1
  • 1
drpepper
  • 165
  • 1
  • 1
  • 11

2 Answers2

2

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
  • 3,522
  • 1
  • 21
  • 12
  • +1 for a solution that works. This wouldn't be the fastest though, `Nokogiri` and `Hpricot` (sigh!) are a lot faster. – Swanand Sep 10 '09 at 15:45
1

This would probably be pretty easy with Nokogiri.

Andy Gaskell
  • 31,495
  • 6
  • 74
  • 83