Module: NbpRates::ClassMethods
- Defined in:
- lib/nbp-rates.rb
Instance Method Summary collapse
Instance Method Details
#nbp_rates_xml ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nbp-rates.rb', line 9 def nbp_rates_xml url = "http://www.nbp.pl/home.aspx?f=/kursy/kursya.html" begin html = Net::HTTP.get(URI.parse(url)) doc = Nokogiri::HTML::Document.parse(html) day_rate_url = "http://www.nbp.pl"+doc.xpath('.//p[@class=\'file print_hidden left\']/a').first['href'] html = Net::HTTP.get(URI.parse(day_rate_url)) XML::Parser.string(html).parse rescue e puts e end end |