adops_report_scrapper 0.2.6 → 0.2.7
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/spotxchange_client.rb +36 -0
- data/lib/adops_report_scrapper/version.rb +1 -1
- data/secret.sample.yml +5 -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: 233ebd6a08873224c62a4d7aa571637d4df47898
|
4
|
+
data.tar.gz: 3955a0a8f90af62e798fb0959624f7b94c752bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75a70e05d63e34ac991166148d148df63143ff9337dcc9b6919568fbce5894ad9042090ca9f247049ef01bf71569d494c59ba9da89989dea65ca829bc9d7732a
|
7
|
+
data.tar.gz: 2814eb614ceba77277a21f71cad0a2844cfc48eca5add03d9a24f420c2d696ebebb6d7974b036fe6bbcf12e566eae586737094f5767f3f32ef4df6b0f32cbc1e
|
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 => [: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] do # openx is the most unstable one, run it first
|
10
|
+
task :all => [: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] do # openx is the most unstable one, run it first
|
11
11
|
puts '========== You are all set'
|
12
12
|
end
|
13
13
|
|
@@ -191,6 +191,11 @@ task :gumgum do
|
|
191
191
|
save_as_csv :gumgum, :gumgum
|
192
192
|
end
|
193
193
|
|
194
|
+
desc 'Collect spotxchange data'
|
195
|
+
task :spotxchange do
|
196
|
+
save_as_csv :spotxchange, :spotxchange
|
197
|
+
end
|
198
|
+
|
194
199
|
def date
|
195
200
|
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
196
201
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
require 'httpclient'
|
4
|
+
|
5
|
+
class AdopsReportScrapper::SpotxchangeClient < AdopsReportScrapper::BaseClient
|
6
|
+
private
|
7
|
+
|
8
|
+
def init_client
|
9
|
+
fail 'please specify spotxchange oauth code' unless @options['code']
|
10
|
+
@code = @options['code']
|
11
|
+
end
|
12
|
+
|
13
|
+
def before_quit_with_error
|
14
|
+
end
|
15
|
+
|
16
|
+
def scrap
|
17
|
+
date_str = @date.strftime('%Y-%m-%d')
|
18
|
+
|
19
|
+
body = { 'client_id' => @login, 'client_secret' => @secret, 'grant_type' => 'authorization_code', 'code' => @code }
|
20
|
+
response = HTTPClient.post 'https://publisher-api.spotxchange.com/1.0/token', body
|
21
|
+
token = JSON.parse(response.body)['value']['data']['access_token']
|
22
|
+
|
23
|
+
header = { 'Authorization' => "Bearer #{token}" }
|
24
|
+
response = HTTPClient.get 'https://api.spotxchange.com/1.0/me', nil, header
|
25
|
+
publisher_id = JSON.parse(response.body)['value']['affiliate_id']
|
26
|
+
|
27
|
+
response = HTTPClient.get "https://api.spotxchange.com/1.0/Publisher(#{publisher_id})/Channels/TrafficReport", { date_range: "#{date_str}|#{date_str}" }, header
|
28
|
+
data = JSON.parse(response.body)['value']['data']
|
29
|
+
|
30
|
+
@data = []
|
31
|
+
|
32
|
+
header = data[0].keys
|
33
|
+
@data = [header]
|
34
|
+
@data += data.map { |datum| header.map { |key| datum[key].is_a?(Hash) ? datum[key]['value'] : datum[key] } }
|
35
|
+
end
|
36
|
+
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.7
|
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-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -263,6 +263,7 @@ files:
|
|
263
263
|
- lib/adops_report_scrapper/rubicon_client.rb
|
264
264
|
- lib/adops_report_scrapper/sonobi_client.rb
|
265
265
|
- lib/adops_report_scrapper/sovrn_client.rb
|
266
|
+
- lib/adops_report_scrapper/spotxchange_client.rb
|
266
267
|
- lib/adops_report_scrapper/springserve_client.rb
|
267
268
|
- lib/adops_report_scrapper/tremor_client.rb
|
268
269
|
- lib/adops_report_scrapper/triplelift_client.rb
|