Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.99 KB | None | 0 0
  1. #require 'pry'
  2. #require 'oga'
  3. require 'nokogiri'
  4. require 'faraday'
  5. require 'faraday-cookie_jar'
  6. require 'timeout'
  7.  
  8. conn = Faraday.new(:url => 'http://proxer.me') do |faraday|
  9.   faraday.use :cookie_jar
  10.   faraday.request  :url_encoded             # form-encode POST params
  11.   # faraday.response :logger                  # log requests to STDOUT
  12.   faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  13.  
  14. end
  15.  
  16. conn.headers[:user_agent] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
  17.  
  18. results = Array.new
  19.  
  20. if ARGV.length >= 2
  21.   username = ARGV[0]
  22.   password = ARGV[1]
  23. else
  24.   puts "USAGE: proxerInfo.rb proxerLogin proxerPassword"
  25.   exit 0
  26. end
  27.        
  28. status = Timeout::timeout(60) {
  29.     begin
  30.         response = conn.get '/'
  31.  
  32.  
  33.         resp = conn.post '/register?format=json&action=login2', {   'username' => username,
  34.                                                                     'password' => password,
  35.                                                                     'secretkey' => '',
  36.                                                                     'remember' => '1'
  37.                                                                 }
  38.                                                                        
  39.     response = conn.get '/components/com_proxer/misc/notifications_misc.php'
  40.    
  41.     #puts response
  42.            
  43.         document = Nokogiri::HTML(response.body)
  44.         res = document.xpath('//*[@class="notificationList"]')
  45.                
  46.  
  47.         res.to_a.each do |element|
  48.             #binding.pry           
  49.             #p element.children.to_a[3].children.text + "::" + element.children.to_a[1].children.text + " ID:" + element.attributes["id"].value + " href:" + "proxer.me" + element.attributes["href"].value
  50.            
  51.             results.push [ element.children.to_a[3].children.text, element.children.to_a[1].children.text, element.attributes["id"].value, element.attributes["href"].value ]
  52.  
  53.         end
  54.     rescue
  55.     # proxer layout changed or response wasn't as expected
  56.     end
  57. }
  58. p results
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. # delete a notification
  68.  
  69. # http://proxer.me/notifications?format=json&s=deleteNotification
  70.  
  71. #id:9134993
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement