Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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