Guest User

Untitled

a guest
Apr 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. require 'net/https'
  2. require "rexml/document"
  3.  
  4. begin
  5.  
  6. username = ""
  7. password = ""
  8.  
  9. today = Time.now
  10. last_week = today - (7 * 86400)
  11. puts "/time/report/0/#{today.strftime("%Y%m%d")}/#{last_week.strftime("%Y%m%d")}"
  12.  
  13. http = Net::HTTP.new("riester.grouphub.com", 443)
  14. http.use_ssl = true
  15. http.start do |http|
  16. req = Net::HTTP::Get.new("/time/report/0/#{today.strftime("%Y%m%d")}/#{last_week.strftime("%Y%m%d")}")
  17. req.basic_auth(username, password)
  18. response = http.request(req)
  19. resp = response.body
  20. doc = REXML::Document.new(resp)
  21. doc.root.elements.each do |elem|
  22. puts elem
  23. end
  24. end
  25. rescue SocketError
  26. raise "Host " + host + " nicht erreichbar"
  27. rescue REXML::ParseException => e
  28. print "error parsing XML " + e.to_s
  29. end
Add Comment
Please, Sign In to add comment