adops_report_scrapper 0.1.63 → 0.1.64
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/sovrn_client.rb +70 -0
- data/lib/adops_report_scrapper/version.rb +1 -1
- data/lib/adops_report_scrapper.rb +1 -0
- 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: d1be985c03d24d672e4dc39e43fd62f9a5678779
|
4
|
+
data.tar.gz: 4ab3bd8a3f93b8fb094ec4f07b797481b1912722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e132376e9695d68fde1204c1badae04521fa43953f4c3c3f3ce453110ddc60d2e50874ab03c39daf42bd981245b98ccb2aa30afc7a7cf20d12b07eb383444885
|
7
|
+
data.tar.gz: bd54236c8f9f2410af5da33209178f0ac1b8856e040f838871f8a2b544cf2437ab058ed68e66729cb7d4b21e1e6d3bcfa137d92493b96f0d62219acdefbd4093
|
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] 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
|
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.1.
|
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-
|
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
|