Guest User

Untitled

a guest
Feb 4th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # encoding: utf-8
  2. # https://www.meteoservice.ru/content/export.html
  3. require 'net/http'
  4. require 'uri'
  5. require 'rexml/document'
  6. require 'mechanize'
  7. require 'json'
  8.  
  9.  
  10. #require_relative "../../lib/decoder.rb"
  11.  
  12. agent = Mechanize.new()
  13.  
  14. town = "Москва"
  15.  
  16. page = agent.get("https://www.meteoservice.ru/location/cities.html?country_id=1")
  17.  
  18. city_list_str = page.search("body").text
  19.  
  20. city_list = JSON.parse(city_list_str)
  21.  
  22. puts city_list['181']
  23.  
  24. el = city_list.select{|key, hash| hash["name"] == town}
  25.  
  26. puts el
  27. puts el.values[0]["point"]
Advertisement
Add Comment
Please, Sign In to add comment