adops_report_scrapper 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/lib/adops_report_scrapper/rhythmone_client.rb +29 -41
- data/lib/adops_report_scrapper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ef9379e7a810f802c7f741f4d44aa61c9354de4
|
4
|
+
data.tar.gz: 7ea5c8aafab042ac43b344723c11598cddb75834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ee246ae6835df0bb846f00c9e9086efb34239defaa9dce2b8e83e339be5185b6292a1d7c5c9a39fd3f7fe0d5868bc8467afd87e7e6ac149cfeaa0fd6e630de
|
7
|
+
data.tar.gz: bc633303cb0745ab0d97ad4f59acc6d5f6e33e766acfc25a8231255c2b34d17e055da1c2392bea3c85960e0b2a4bcc580b4ef4ac789102fbbde291b4fc55685a
|
data/CHANGELOG
CHANGED
@@ -1,56 +1,44 @@
|
|
1
1
|
require 'date'
|
2
2
|
require_relative 'base_client'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'httpclient'
|
3
5
|
|
4
6
|
class AdopsReportScrapper::RhythmoneClient < AdopsReportScrapper::BaseClient
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
sleep 1
|
10
|
-
return if @client.find_all(:xpath, '//*[contains(text(),"REPORTING")]').count > 0
|
11
|
-
@client.fill_in 'email', :with => @login
|
12
|
-
@client.fill_in 'password', :with => @secret
|
13
|
-
@client.click_button 'Sign in'
|
14
|
-
|
15
|
-
begin
|
16
|
-
@client.find :xpath, '//*[contains(text(),"REPORTING")]'
|
17
|
-
rescue Exception => e
|
18
|
-
raise e, 'Rhythmone login error'
|
19
|
-
end
|
7
|
+
def date_supported?(date = nil)
|
8
|
+
_date = date || @date
|
9
|
+
return true if _date >= Date.today - 3
|
10
|
+
false
|
20
11
|
end
|
21
12
|
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
private
|
14
|
+
|
15
|
+
def init_client
|
16
|
+
fail 'please specify rhythmone client_id' unless @options['client_id']
|
17
|
+
fail 'please specify rhythmone client_secret' unless @options['client_secret']
|
18
|
+
fail 'please specify rhythmone publisher_id' unless @options['publisher_id']
|
19
|
+
@client_id = @options['client_id']
|
20
|
+
@client_secret = @options['client_secret']
|
21
|
+
@publisher_id = @options['publisher_id']
|
25
22
|
end
|
26
23
|
|
27
|
-
def
|
28
|
-
@client.find(:xpath, '//*[contains(text(),"REPORTING")]').click
|
29
|
-
wait_for_loading
|
30
|
-
@client.find(:xpath, '//option[contains(text(),"Yesterday")]').select_option
|
31
|
-
sleep 1
|
32
|
-
@client.find(:xpath, '//select[@ng-model="filter.group1"]').find(:xpath, 'option[contains(text(),"Placement")]').select_option
|
33
|
-
wait_for_loading
|
34
|
-
@client.click_button 'Generate report'
|
35
|
-
sleep 2
|
36
|
-
wait_for_loading
|
24
|
+
def before_quit_with_error
|
37
25
|
end
|
38
26
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
@
|
27
|
+
def login
|
28
|
+
response = RestClient.post 'https://api.portal.rhythmone.com/v1/users/login', client_id: @client_id, client_secret: @client_secret, grant_type: 'password', password: @secret, username: @login
|
29
|
+
token_obj = JSON.parse response.body
|
30
|
+
@access_token = token_obj['access_token']
|
43
31
|
end
|
44
32
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
sleep
|
33
|
+
def scrap
|
34
|
+
date_str = @date.strftime('%Y%m%d')
|
35
|
+
data_obj = nil
|
36
|
+
5.times do
|
37
|
+
response = HTTPClient.get("https://api.portal.rhythmone.com/v1/publishers/#{@publisher_id}/reports/standard_report", { ad_dimension: 0, endDate: date_str, endDateType: 1, groupBy1: 1, groupByTimePeriodType: 1, rmp_placement: 0, startDate: date_str, startDatePredefined: 0, startDateType: 1 }, { 'Authorization' => "Bearer #{@access_token}" })
|
38
|
+
data_obj = JSON.parse response.body
|
39
|
+
break if data_obj.is_a? Array
|
40
|
+
sleep 5
|
53
41
|
end
|
54
|
-
|
42
|
+
@data = data_obj
|
55
43
|
end
|
56
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adops_report_scrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stayman Hou
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|