retrieving page title in rails
-
05-07-2019 - |
Question
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!
Solution
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
OTHER TIPS
This would probably be pretty easy with Nokogiri.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow