drpepper
drpepper

Reputation: 165

retrieving page title in rails

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!

Upvotes: 0

Views: 360

Answers (2)

Thorbj&#248;rn Hermansen
Thorbj&#248;rn Hermansen

Reputation: 3552

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

Upvotes: 2

Andy Gaskell
Andy Gaskell

Reputation: 31761

This would probably be pretty easy with Nokogiri.

Upvotes: 1

Related Questions