adops_report_scrapper 0.2.34 → 0.2.35
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/Rakefile +6 -1
- data/lib/adops_report_scrapper.rb +1 -0
- data/lib/adops_report_scrapper/indexexchange_client.rb +46 -0
- data/lib/adops_report_scrapper/version.rb +1 -1
- data/secret.sample.yml +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9a80c798f022a79269546a5f1fb2f8e99921b06
|
4
|
+
data.tar.gz: 37cf1e17c2ad5e7837ff1e90936015fd5b232aaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3adf61abd8e28530eb3d5bcf1ff16d6c799d135c16bf03096a1a978e5e6e2dd2885c27753fdb1e60469d2e988fbb82a5d2c977811a094cc39a74000acde1438e
|
7
|
+
data.tar.gz: 3053718c47f72ee09e5f1d0bd5d43145a46cdd398ebe1c71916bff8ebc0157d8eb2d0fbe3fe521c7fc7fff1c9f5a23dd32b38104628dbaaf1f1c1d2d995f57d9
|
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'adops_report_scrapper'
|
|
7
7
|
require 'byebug'
|
8
8
|
|
9
9
|
desc 'Collect all data'
|
10
|
-
task :all => [:anyclip, :openx, :tremor, :brightroll, :yellowhammer, :adaptv, :fourninefive, :adx, :revcontent, :gcs, :browsi, :netseer, :sonobi, :nativo, :adsupply, :marfeel, :adsense, :criteo, :triplelift, :conversant, :liveintent, :adiply, :contentad, :facebookaudience, :adtechus, :adtomation, :rhythmone, :littlethings, :appnexus, :sovrn, :spotxchange, :lkqd] do # openx is the most unstable one, run it first
|
10
|
+
task :all => [:anyclip, :openx, :tremor, :brightroll, :yellowhammer, :adaptv, :fourninefive, :adx, :revcontent, :gcs, :browsi, :netseer, :sonobi, :nativo, :adsupply, :marfeel, :adsense, :criteo, :triplelift, :conversant, :liveintent, :adiply, :contentad, :facebookaudience, :adtechus, :adtomation, :rhythmone, :littlethings, :appnexus, :sovrn, :spotxchange, :lkqd, :indexexchange] do # openx is the most unstable one, run it first
|
11
11
|
puts '========== You are all set'
|
12
12
|
end
|
13
13
|
|
@@ -226,6 +226,11 @@ task :lkqd do
|
|
226
226
|
save_as_csv :lkqd, :lkqd
|
227
227
|
end
|
228
228
|
|
229
|
+
desc 'Collect indexexchange data'
|
230
|
+
task :indexexchange do
|
231
|
+
save_as_csv :indexexchange, :indexexchange
|
232
|
+
end
|
233
|
+
|
229
234
|
def date
|
230
235
|
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
231
236
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
class AdopsReportScrapper::IndexexchangeClient < AdopsReportScrapper::BaseClient
|
6
|
+
def date_supported?(date = nil)
|
7
|
+
_date = date || @date
|
8
|
+
return true if _date < (Date.today + 1)
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
def init_client
|
13
|
+
end
|
14
|
+
|
15
|
+
def before_quit_with_error
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def scrap
|
21
|
+
date_str = @date.strftime('%Y-%m-%d')
|
22
|
+
|
23
|
+
response = RestClient.post 'https://auth.indexexchange.com/auth/oauth/token', { 'username' => @login, 'key' => @secret }.to_json, { 'Content-Type' => 'application/json; charset=utf-8' }
|
24
|
+
access_token = JSON.parse(response)['data']['accessToken']
|
25
|
+
|
26
|
+
header = { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json; charset=utf-8' }
|
27
|
+
|
28
|
+
response = RestClient.post 'https://api01.indexexchange.com/api/publishers/sites', '', header
|
29
|
+
site_tag_map = JSON.parse(response)['data'].map { |e| [e['siteID'], e['name']] }.to_h
|
30
|
+
|
31
|
+
response = RestClient.post 'https://api01.indexexchange.com/api/publishers/stats/earnings/open', { 'filters' => { 'startDate' => date_str, 'endDate' => date_str }, 'aggregation' => 'siteID' }.to_json, header
|
32
|
+
data = JSON.parse(response)['data'].each do |datum|
|
33
|
+
datum['siteTagName'] = site_tag_map[datum['aggregateID']]
|
34
|
+
end
|
35
|
+
|
36
|
+
unless data[0]
|
37
|
+
@data = []
|
38
|
+
return
|
39
|
+
end
|
40
|
+
header = data[0].keys
|
41
|
+
@data = [header]
|
42
|
+
@data += data.map do |datum|
|
43
|
+
header.map { |key| datum[key] }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/secret.sample.yml
CHANGED
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.2.
|
4
|
+
version: 0.2.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stayman Hou
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -269,6 +269,7 @@ files:
|
|
269
269
|
- lib/adops_report_scrapper/gcs_client.rb
|
270
270
|
- lib/adops_report_scrapper/gumgum_client.rb
|
271
271
|
- lib/adops_report_scrapper/imonomy_client.rb
|
272
|
+
- lib/adops_report_scrapper/indexexchange_client.rb
|
272
273
|
- lib/adops_report_scrapper/littlethings_client.rb
|
273
274
|
- lib/adops_report_scrapper/liveintent_client.rb
|
274
275
|
- lib/adops_report_scrapper/lkqd_client.rb
|