require 'sinatra' require 'hpricot' require 'open-uri' set :server, 'webrick' class Page def initialize(link) @link = "https://facebook.com/" + link doc = Hpricot(open(@link)) @title = (doc/"title").inner_text end def link @link end def title @title end end get '/' do str = File.read('source.html') id = /\d{5,20}/ @matches = str.scan id @pages = [] @matches.each do |id| @pages << Page.new(id) end erb :index end #index.erb <% @pages.each do |page| %>

><%= page.link %> | <%= page.title %>

<% end %>