Extracting web page title
1 2 require 'open-uri' 3 4 URI.parse('http://google.es').open do |f| 5 f.each {|l| if md = (/<title>\s*(.*)\s*<\/title>/iu).match(l) then print md[1] end } 6 end
DZone Snippets > demimismo > title
12750 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
David Arango http://mildiez.net
1 2 require 'open-uri' 3 4 URI.parse('http://google.es').open do |f| 5 f.each {|l| if md = (/<title>\s*(.*)\s*<\/title>/iu).match(l) then print md[1] end } 6 end