Sha256: 836c19410ce698ff971d6a6e1f46c4bb39c2347540c1bf57e87ca3964ae0a8c5
Contents?: true
Size: 1.36 KB
Versions: 119
Compression:
Stored size: 1.36 KB
Contents
require 'date' require_relative 'base_client' class AdopsReportScrapper::NativoClient < AdopsReportScrapper::BaseClient private def login @client.visit 'https://admin.nativo.net/' @client.fill_in 'Email', :with => @login @client.fill_in 'Password', :with => @secret @client.click_button 'Log In' begin @client.find :xpath, '//*[text()="Reports"]' rescue Exception => e raise e, 'Nativo login error' end end def scrap request_report extract_data_from_report end def request_report @client.click_link 'Reports' @client.click_link 'Marketplace Campaigns' sleep 1 @client.find(:css, '.date-range').click sleep 1 @client.find(:xpath, '//*[text()="Yesterday"]').click @client.check 'Publisher' @client.check 'Device' @client.check 'Clicks' @client.check 'Publisher Revenue' @client.check 'Video Views' @client.check 'Video Views to 100%' sleep 1 wait_for_loading end def extract_data_from_report rows = @client.find_all :xpath, '//div/table/*[self::thead|self::tbody]/tr' @data = rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } } end def wait_for_loading 30.times do |_i| # wait 5 min begin @client.find(:css, '.loading') rescue Exception => e break end sleep 10 end sleep 1 end end
Version data entries
119 entries across 119 versions & 1 rubygems