adops_report_scrapper 0.1.63 → 0.1.64

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b29f1d05de51d3ef2689d26ca63ff3585f91df7
4
- data.tar.gz: c51a258913261369cc6fc110ce63d45dd2d612ce
3
+ metadata.gz: d1be985c03d24d672e4dc39e43fd62f9a5678779
4
+ data.tar.gz: 4ab3bd8a3f93b8fb094ec4f07b797481b1912722
5
5
  SHA512:
6
- metadata.gz: 0b4141e2dd50f23956c091b0fe85b54801b3ea0ea5edea674da7fa8db85e6709992fef47ff81f6dc17eb941cfba09f57e734738c2b19de799379399a873db9d0
7
- data.tar.gz: 8b6fd7fe2aaeab350c5c84301e7a4c34d8885182f740a77da531deb1855ee7150f7016512578df3466321de9fc23d6e12e382c681e3aa4095d15d17a40efbed3
6
+ metadata.gz: e132376e9695d68fde1204c1badae04521fa43953f4c3c3f3ce453110ddc60d2e50874ab03c39daf42bd981245b98ccb2aa30afc7a7cf20d12b07eb383444885
7
+ data.tar.gz: bd54236c8f9f2410af5da33209178f0ac1b8856e040f838871f8a2b544cf2437ab058ed68e66729cb7d4b21e1e6d3bcfa137d92493b96f0d62219acdefbd4093
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.64
4
+ implement sovrn
5
+
3
6
  ## 0.1.63
4
7
  fix adaptv/onevideo after their UI update
5
8
 
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] 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] do # openx is the most unstable one, run it first
11
11
  puts '========== You are all set'
12
12
  end
13
13
 
@@ -181,6 +181,11 @@ task :appnexus do
181
181
  save_as_csv :appnexus, :appnexus
182
182
  end
183
183
 
184
+ desc 'Collect sovrn data'
185
+ task :sovrn do
186
+ save_as_csv :sovrn, :sovrn
187
+ end
188
+
184
189
  def date
185
190
  @date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
186
191
  end
@@ -0,0 +1,70 @@
1
+ require 'date'
2
+ require_relative 'base_client'
3
+
4
+ class AdopsReportScrapper::SovrnClient < AdopsReportScrapper::BaseClient
5
+ def date_supported?(date = nil)
6
+ _date = date || @date
7
+ return true if _date >= Date.today - 7
8
+ false
9
+ end
10
+
11
+ private
12
+
13
+ def login
14
+ @client.visit 'https://meridian.sovrn.com/#welcome'
15
+ sleep 5
16
+ if @client.find_all(:css, '#user-menu-trigger').count > 0
17
+ @client.find_all(:css, '#user-menu-trigger').first.click
18
+ sleep 1
19
+ @client.find(:xpath, '//li[@data-value="logout"]').click
20
+ end
21
+ @client.fill_in 'login_username', :with => @login
22
+ @client.fill_in 'login_password', :with => @secret
23
+ @client.click_link 'Log In'
24
+
25
+ begin
26
+ @client.find :xpath, '//*[text()="Account"]'
27
+ rescue Exception => e
28
+ raise e, 'sovrn login error'
29
+ end
30
+ end
31
+
32
+ def scrap
33
+ request_report
34
+ extract_data_from_report
35
+ end
36
+
37
+ def request_report
38
+ @client.visit 'https://meridian.sovrn.com/#account/my_downloads'
39
+ @client.save_screenshot
40
+ sleep 5
41
+ if @client.find_all(:xpath, '//input[@value="domestic_and_international"]').count == 0
42
+ login
43
+ @client.visit 'https://meridian.sovrn.com/#account/my_downloads'
44
+ sleep 5
45
+ end
46
+ @client.find(:xpath, '//input[@value="domestic_and_international"]').set(true)
47
+
48
+ @client.fill_in 'adstats-date-range-start-month', :with => @date.strftime('%m')
49
+ @client.fill_in 'adstats-date-range-start-day', :with => @date.strftime('%d')
50
+ @client.fill_in 'adstats-date-range-start-year', :with => @date.strftime('%Y')
51
+
52
+ @client.fill_in 'adstats-date-range-end-month', :with => @date.strftime('%m')
53
+ @client.fill_in 'adstats-date-range-end-day', :with => @date.strftime('%d')
54
+ @client.fill_in 'adstats-date-range-end-year', :with => @date.strftime('%Y')
55
+
56
+ @client.find_all(:xpath, '//button[text()=" Download "]').first.click
57
+
58
+ sleep 2
59
+
60
+ url = @client.driver.network_traffic[-1].url
61
+ headers = @client.driver.network_traffic[-1].headers
62
+
63
+ @response = HTTPClient.get url, header: headers.map{ |header| [header['name'], header['value']] }.to_h
64
+ end
65
+
66
+ def extract_data_from_report
67
+ rows = CSV.parse @response.body
68
+ @data = rows[6..-1]
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.1.63"
2
+ VERSION = "0.1.64"
3
3
  end
@@ -47,3 +47,4 @@ require 'adops_report_scrapper/imonomy_client'
47
47
  require 'adops_report_scrapper/positivemobile_client'
48
48
  require 'adops_report_scrapper/brightcom_client'
49
49
  require 'adops_report_scrapper/appnexus_client'
50
+ require 'adops_report_scrapper/sovrn_client'
data/secret.sample.yml CHANGED
@@ -120,3 +120,6 @@ brightcom:
120
120
  appnexus:
121
121
  login: ------
122
122
  secret: ------
123
+ sovrn:
124
+ login: ------
125
+ secret: ------
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.63
4
+ version: 0.1.64
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-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -247,6 +247,7 @@ files:
247
247
  - lib/adops_report_scrapper/rhythmone_client.rb
248
248
  - lib/adops_report_scrapper/rubicon_client.rb
249
249
  - lib/adops_report_scrapper/sonobi_client.rb
250
+ - lib/adops_report_scrapper/sovrn_client.rb
250
251
  - lib/adops_report_scrapper/springserve_client.rb
251
252
  - lib/adops_report_scrapper/tremor_client.rb
252
253
  - lib/adops_report_scrapper/triplelift_client.rb