adops_report_scrapper 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/adops_report_scrapper/adsense_client.rb +9 -2
- data/lib/adops_report_scrapper/adsupply_client.rb +6 -0
- data/lib/adops_report_scrapper/adx_client.rb +9 -2
- data/lib/adops_report_scrapper/sonobi_client.rb +17 -2
- 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: 10e30e07782bffd3f6b6e2dc3a5774f8f91196b3
|
4
|
+
data.tar.gz: 748a6a341e21f648cd5b0291ded6d1e6c3dad686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e9a718dc2bb16862cba915583bacc1c369a6835812f0123516065f83d447d16d06bf2d4fa40c53e39da0ac4efc76a2e3f8dada1d36c053a1c3d388976c775b2
|
7
|
+
data.tar.gz: 2d851c270ec6e056aa27cd69098817b490964266fb403d0b9487b3a7c2da1dff7a8cac097136937b0051399f99970a4e67a3116e06de137a4ccd3a4624002735
|
@@ -14,6 +14,12 @@ class AdopsReportScrapper::AdsenseClient < AdopsReportScrapper::BaseClient
|
|
14
14
|
CREDENTIAL_STORE_FILE = "#{API_NAME}-oauth2.json"
|
15
15
|
API_SCOPE = 'https://www.googleapis.com/auth/adsense.readonly'
|
16
16
|
|
17
|
+
def date_supported?(date = nil)
|
18
|
+
_date = date || @date
|
19
|
+
return true if _date < Date.today
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
17
23
|
private
|
18
24
|
|
19
25
|
def init_client
|
@@ -43,10 +49,11 @@ class AdopsReportScrapper::AdsenseClient < AdopsReportScrapper::BaseClient
|
|
43
49
|
end
|
44
50
|
|
45
51
|
def scrap
|
52
|
+
date_str = @date.strftime('%Y-%m-%d')
|
46
53
|
result = @client.accounts.reports.generate(
|
47
54
|
:accountId => @account_id,
|
48
|
-
:startDate =>
|
49
|
-
:endDate =>
|
55
|
+
:startDate => date_str,
|
56
|
+
:endDate => date_str,
|
50
57
|
:metric => ['AD_REQUESTS', 'INDIVIDUAL_AD_IMPRESSIONS', 'CLICKS', 'EARNINGS'],
|
51
58
|
:dimension => ['DATE', 'AD_UNIT_CODE', 'AD_UNIT_NAME', 'COUNTRY_CODE', 'PLATFORM_TYPE_NAME'],
|
52
59
|
:alt => 'csv').execute
|
@@ -3,6 +3,12 @@ require_relative 'base_client'
|
|
3
3
|
require 'rest-client'
|
4
4
|
|
5
5
|
class AdopsReportScrapper::AdsupplyClient < AdopsReportScrapper::BaseClient
|
6
|
+
def date_supported?(date = nil)
|
7
|
+
_date = date || @date
|
8
|
+
return true if _date < Date.today
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
6
12
|
def init_client
|
7
13
|
end
|
8
14
|
|
@@ -14,6 +14,12 @@ class AdopsReportScrapper::AdxClient < AdopsReportScrapper::BaseClient
|
|
14
14
|
CREDENTIAL_STORE_FILE = "#{API_NAME}-oauth2.json"
|
15
15
|
API_SCOPE = 'https://www.googleapis.com/auth/adexchange.seller.readonly'
|
16
16
|
|
17
|
+
def date_supported?(date = nil)
|
18
|
+
_date = date || @date
|
19
|
+
return true if _date < Date.today
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
17
23
|
private
|
18
24
|
|
19
25
|
def init_client
|
@@ -43,10 +49,11 @@ class AdopsReportScrapper::AdxClient < AdopsReportScrapper::BaseClient
|
|
43
49
|
end
|
44
50
|
|
45
51
|
def scrap
|
52
|
+
date_str = @date.strftime('%Y-%m-%d')
|
46
53
|
result = @client.accounts.reports.generate(
|
47
54
|
:accountId => @account_id,
|
48
|
-
:startDate =>
|
49
|
-
:endDate =>
|
55
|
+
:startDate => date_str,
|
56
|
+
:endDate => date_str,
|
50
57
|
:metric => ['AD_REQUESTS', 'AD_IMPRESSIONS', 'CLICKS', 'EARNINGS'],
|
51
58
|
:dimension => ['DATE', 'DFP_AD_UNITS', 'DFP_AD_UNIT_ID', 'COUNTRY_CODE', 'PLATFORM_TYPE_NAME'],
|
52
59
|
:alt => 'csv').execute
|
@@ -2,6 +2,12 @@ require 'date'
|
|
2
2
|
require_relative 'base_client'
|
3
3
|
|
4
4
|
class AdopsReportScrapper::SonobiClient < AdopsReportScrapper::BaseClient
|
5
|
+
def date_supported?(date = nil)
|
6
|
+
_date = date || @date
|
7
|
+
return true if _date >= Date.today - 2
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
5
11
|
private
|
6
12
|
|
7
13
|
def login
|
@@ -25,10 +31,19 @@ class AdopsReportScrapper::SonobiClient < AdopsReportScrapper::BaseClient
|
|
25
31
|
end
|
26
32
|
|
27
33
|
def request_report(country)
|
34
|
+
date_str = @date.strftime('%Y-%m-%d')
|
28
35
|
is_us = country == :us
|
29
|
-
# all sites
|
30
36
|
@client.find(:xpath, '//*[text()="Reports"]').click
|
31
37
|
sleep 2
|
38
|
+
# set date
|
39
|
+
@client.select 'Custom'
|
40
|
+
sleep 1
|
41
|
+
@client.find(:xpath, '//input[@name="_range_start_date"]').click
|
42
|
+
@client.find(:xpath, "//*[@date=\"#{date_str}\"]").click
|
43
|
+
@client.find(:xpath, '//input[@name="_range_end_date"]').click
|
44
|
+
@client.find(:xpath, "//*[@date=\"#{date_str}\"]").click
|
45
|
+
|
46
|
+
# all sites
|
32
47
|
@client.find(:xpath, '//div[@name="_siteid"]').click
|
33
48
|
sleep 2
|
34
49
|
@client.find(:xpath, '//*[text()="Select All"]').click
|
@@ -88,4 +103,4 @@ class AdopsReportScrapper::SonobiClient < AdopsReportScrapper::BaseClient
|
|
88
103
|
end
|
89
104
|
sleep 5
|
90
105
|
end
|
91
|
-
end
|
106
|
+
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.4
|
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-08-
|
11
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|