Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LigthingTalk: Sinatra + Hpricot

Duke
September 18, 2010

LigthingTalk: Sinatra + Hpricot

Uma LigthingTalk no #GuruSP, um das minha primeiras apresetações

Duke

September 18, 2010
Tweet

More Decks by Duke

Other Decks in Programming

Transcript

  1. $ ruby app.rb Raspando dados com Sinatra e Hpricot

  2. { name: 'Emerson Vinicius', github: 'emersonvinicius ' }

  3. Sinatra

  4. require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end

  5. require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end

  6. require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end

  7. require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end

  8. Hpricot

  9. None
  10. require 'rubygems' require 'open-uri' require 'hpricot' url = 'http://br.weather.yahoo.com/brazil/sao-paulo/sao- paulo-455827/'

    tempo = Hpricot(open(url).read) (tempo/"[@id='yw-temp']").inner_text // 27°
  11. require 'rubygems' require 'open-uri' require 'hpricot' url = 'http://br.weather.yahoo.com/brazil/sao-paulo/sao- paulo-455827/'

    tempo = Hpricot(open(url).read) (tempo/"[@id='yw-temp']").inner_text // 27°
  12. require 'rubygems' require 'open-uri' require 'hpricot' url = 'http://br.weather.yahoo.com/brazil/sao-paulo/sao- paulo-455827/'

    tempo = Hpricot(open(url).read) (tempo/"[@id='yw-temp']").inner_text // 27°
  13. require 'rubygems' require 'open-uri' require 'hpricot' url = 'http://br.weather.yahoo.com/brazil/sao-paulo/sao- paulo-455827/'

    tempo = Hpricot(open(url).read) (tempo/"[@id='yw-temp']").inner_text // 27° #WIN
  14. O que fazer com isso?

  15. None
  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. { name: 'Emerson Vinicius', twitter: '@emersonvinicius', gtalk: 'duke.m16', github: 'emersonvinicius

    ' } Obrigado!