SHARE
TWEET

Untitled

a guest Jun 13th, 2012 45 Never
  1. require 'mechanize'
  2. require 'yaml'
  3.  
  4. debug = File.new("/tmp/ipcamera", "w+")
  5. device_.devdata_.each do |d, k|
  6. debug.print "#{d}: #{k}\n"
  7. end
  8. debug.close()
  9.  
  10.  
  11. c = WWW::Mechanize.new
  12. c.get("http://#{device_.devdata_[299]}") do |login_page|
  13. login_form = login_page.forms[0]
  14. login_form.username = device_.devdata_[114]
  15. login_form.password = device_.devdata_[115]
  16. login_response = login_form.submit
  17.  
  18. if login_response.title == "Login"
  19. puts "Login Failed"
  20. else
  21. c.get("http://#{device_.devdata_[299]}/#{device_.devdata_[2]}") do |image|
  22. if image.header["Content-type"] == "image/jpeg"
  23. data_set(image.body)
  24. format_set('jpg')
  25. else
  26. puts "Failed to retrieve image, login may have failed"
  27. end
  28. end
  29. end
  30. end
RAW Paste Data
Top