Guest User

Untitled

a guest
Apr 17th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.55 KB | None | 0 0
  1. require 'nokogiri'
  2.  
  3. page = Nokogiri::HTML(open("dn.html"))
  4. td = page.xpath('/html/body/div[1]/table[6]//tr[2]//td')
  5. text_content = td.text.delete("\n").delete("\r")
  6. regex = /([\w-]{9})(.*)Pot\. Poluidor.*Geral:(.*)Porte:(.*): Pequeno(.*): Médio(.*): Grande/
  7. match = text_content.match(regex)
  8.  
  9. text = match[6]
  10.  
  11. text.chars.each do |x|
  12.     p x + "  -  " + x.ord.to_s + "  -  " + (x.ord == [160].pack('U')).to_s
  13. end
  14.  
  15. # OUTPUT
  16. # "n  -  110  -  false"
  17. # "o  -  111  -  false"
  18. # "   -  160  -  false"
  19. # "   -  160  -  false"
  20. # "   -  32  -  false"
Advertisement
Add Comment
Please, Sign In to add comment