class Dtcrandom0::Application

Public Instance Methods

run() click to toggle source
# File lib/dtcrandom0.rb, line 6
def run
  num = ARGV[0].to_i() - 1
  domain = 'http://danstonchat.com'
  url = domain + '/random0.html'
  page = Hpricot(open(url))
  page.search('//div.item')[0..num].each{|node|
    quote = node.search('//.item-content/a').html()
    permalink = node.search('//.item-meta//span//a')[0]&.get_attribute('href')
    puts " * %s : " % permalink
    puts HTMLEntities.new.decode quote.gsub(/<\/?span[^>]*>/, '').gsub(/<br[^>]*>/, '')
    puts
  }
end