adops_report_scrapper 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/Rakefile +11 -1
- data/lib/adops_report_scrapper/adforge_client.rb +4 -1
- data/lib/adops_report_scrapper/adtomation_client.rb +50 -0
- data/lib/adops_report_scrapper/rhythmone_client.rb +55 -0
- data/lib/adops_report_scrapper/version.rb +1 -1
- data/lib/adops_report_scrapper.rb +4 -2
- data/secret.sample.yml +6 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54ac8cdf2da487d3e2724718e72c3d27ca1139ce
|
4
|
+
data.tar.gz: d699316c998e1441290026fc8e689a67f5f16b64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07190bedabc4eced4195404044b7e40d6795e58f9948ef9df8156995fce278367dfdae3e20aa29f514630ddb24cfe0e8a07614ddcfc5d9cd608e36ca9769aae2
|
7
|
+
data.tar.gz: f539866ab7a944d64d6ddde8406f3da7825e4462dcdf0ef32bed1e88d645b6a4840a9d8990cffe0871170e93012c73d5a71b50a042042afd38ed1f102bbba53c
|
data/CHANGELOG
ADDED
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] 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] do # openx is the most unstable one, run it first
|
11
11
|
puts '========== You are all set'
|
12
12
|
end
|
13
13
|
|
@@ -136,6 +136,16 @@ task :divisiond do
|
|
136
136
|
save_as_csv :divisiond, :zedo
|
137
137
|
end
|
138
138
|
|
139
|
+
desc 'Collect adtomation data'
|
140
|
+
task :adtomation do
|
141
|
+
save_as_csv :adtomation, :adtomation
|
142
|
+
end
|
143
|
+
|
144
|
+
desc 'Collect rhythmone data'
|
145
|
+
task :rhythmone do
|
146
|
+
save_as_csv :rhythmone, :rhythmone
|
147
|
+
end
|
148
|
+
|
139
149
|
def date
|
140
150
|
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
141
151
|
end
|
@@ -22,7 +22,10 @@ class AdopsReportScrapper::AdforgeClient < AdopsReportScrapper::BaseClient
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def request_report
|
25
|
-
@client.find(:
|
25
|
+
@client.within_frame @client.find(:tag, :iframe) do
|
26
|
+
@client.find(:xpath, '//option[text()="Yesterday"]').select_option
|
27
|
+
@client.click_button 'Submit'
|
28
|
+
end
|
26
29
|
sleep 5
|
27
30
|
end
|
28
31
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
|
4
|
+
class AdopsReportScrapper::AdtomationClient < AdopsReportScrapper::BaseClient
|
5
|
+
private
|
6
|
+
|
7
|
+
def login
|
8
|
+
@client.visit 'http://console.adtomation.com/'
|
9
|
+
@client.fill_in 'Username', :with => @login
|
10
|
+
@client.fill_in 'Password', :with => @secret
|
11
|
+
@client.click_button 'Sign In'
|
12
|
+
|
13
|
+
begin
|
14
|
+
@client.find :xpath, '//*[text()="Reporting"]'
|
15
|
+
rescue Exception => e
|
16
|
+
raise e, 'Adtomation login error'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def scrap
|
21
|
+
request_report
|
22
|
+
extract_data_from_report
|
23
|
+
end
|
24
|
+
|
25
|
+
def request_report
|
26
|
+
@client.click_link 'Your Reports'
|
27
|
+
@client.find(:xpath, '//*[../../../../../td[text()="report created by adops report scrapper"] and contains(text(),"Run")]').click
|
28
|
+
sleep 5
|
29
|
+
wait_for_loading
|
30
|
+
end
|
31
|
+
|
32
|
+
def extract_data_from_report
|
33
|
+
rows = @client.find_all :xpath, '//table/*/tr'
|
34
|
+
rows = rows.to_a
|
35
|
+
rows.pop
|
36
|
+
@data = rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } }
|
37
|
+
end
|
38
|
+
|
39
|
+
def wait_for_loading
|
40
|
+
30.times do |_i| # wait 5 min
|
41
|
+
begin
|
42
|
+
@client.find(:xpath, '//*[text()="Loading..."]')
|
43
|
+
rescue Exception => e
|
44
|
+
break
|
45
|
+
end
|
46
|
+
sleep 10
|
47
|
+
end
|
48
|
+
sleep 2
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
|
4
|
+
class AdopsReportScrapper::RhythmoneClient < AdopsReportScrapper::BaseClient
|
5
|
+
private
|
6
|
+
|
7
|
+
def login
|
8
|
+
@client.visit 'https://portal.rhythmone.com/login'
|
9
|
+
sleep 1
|
10
|
+
@client.fill_in 'email', :with => @login
|
11
|
+
@client.fill_in 'password', :with => @secret
|
12
|
+
@client.click_button 'Sign in'
|
13
|
+
|
14
|
+
begin
|
15
|
+
@client.find :xpath, '//*[contains(text(),"REPORTING")]'
|
16
|
+
rescue Exception => e
|
17
|
+
raise e, 'Rhythmone login error'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def scrap
|
22
|
+
request_report
|
23
|
+
extract_data_from_report
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_report
|
27
|
+
@client.find(:xpath, '//*[contains(text(),"REPORTING")]').click
|
28
|
+
wait_for_loading
|
29
|
+
@client.find(:xpath, '//option[contains(text(),"Yesterday")]').select_option
|
30
|
+
sleep 1
|
31
|
+
@client.find(:xpath, '//select[@ng-model="filter.group1"]').find(:xpath, 'option[contains(text(),"Placement")]').select_option
|
32
|
+
wait_for_loading
|
33
|
+
@client.click_button 'Generate report'
|
34
|
+
sleep 1
|
35
|
+
wait_for_loading
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract_data_from_report
|
39
|
+
rows = @client.find_all :xpath, '//table/*/tr'
|
40
|
+
rows = rows.to_a
|
41
|
+
@data = rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } }
|
42
|
+
end
|
43
|
+
|
44
|
+
def wait_for_loading
|
45
|
+
30.times do |_i| # wait 5 min
|
46
|
+
begin
|
47
|
+
@client.find(:xpath, '//overlay-spinner/div')
|
48
|
+
rescue Exception => e
|
49
|
+
break
|
50
|
+
end
|
51
|
+
sleep 10
|
52
|
+
end
|
53
|
+
sleep 2
|
54
|
+
end
|
55
|
+
end
|
@@ -14,7 +14,7 @@ module AdopsReportScrapper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
require 'adops_report_scrapper/adaptv_client'
|
17
|
-
require 'adops_report_scrapper/adforge_client'
|
17
|
+
# require 'adops_report_scrapper/adforge_client'
|
18
18
|
require 'adops_report_scrapper/adiply_client'
|
19
19
|
require 'adops_report_scrapper/adsense_client'
|
20
20
|
require 'adops_report_scrapper/adsupply_client'
|
@@ -35,6 +35,8 @@ require 'adops_report_scrapper/revcontent_client'
|
|
35
35
|
require 'adops_report_scrapper/sonobi_client'
|
36
36
|
require 'adops_report_scrapper/springserve_client'
|
37
37
|
require 'adops_report_scrapper/tremor_client'
|
38
|
-
require 'adops_report_scrapper/triplelift_client'
|
38
|
+
# require 'adops_report_scrapper/triplelift_client'
|
39
39
|
require 'adops_report_scrapper/adtechus_client'
|
40
40
|
require 'adops_report_scrapper/zedo_client'
|
41
|
+
require 'adops_report_scrapper/adtomation_client'
|
42
|
+
require 'adops_report_scrapper/rhythmone_client'
|
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.20
|
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-10-
|
11
|
+
date: 2016-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- ".gitignore"
|
208
208
|
- ".rspec"
|
209
209
|
- ".travis.yml"
|
210
|
+
- CHANGELOG
|
210
211
|
- CODE_OF_CONDUCT.md
|
211
212
|
- Gemfile
|
212
213
|
- LICENSE.txt
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- lib/adops_report_scrapper/adsense_client.rb
|
223
224
|
- lib/adops_report_scrapper/adsupply_client.rb
|
224
225
|
- lib/adops_report_scrapper/adtechus_client.rb
|
226
|
+
- lib/adops_report_scrapper/adtomation_client.rb
|
225
227
|
- lib/adops_report_scrapper/adx_client.rb
|
226
228
|
- lib/adops_report_scrapper/base_client.rb
|
227
229
|
- lib/adops_report_scrapper/brightroll_client.rb
|
@@ -237,6 +239,7 @@ files:
|
|
237
239
|
- lib/adops_report_scrapper/netseer_client.rb
|
238
240
|
- lib/adops_report_scrapper/openx_client.rb
|
239
241
|
- lib/adops_report_scrapper/revcontent_client.rb
|
242
|
+
- lib/adops_report_scrapper/rhythmone_client.rb
|
240
243
|
- lib/adops_report_scrapper/sonobi_client.rb
|
241
244
|
- lib/adops_report_scrapper/springserve_client.rb
|
242
245
|
- lib/adops_report_scrapper/tremor_client.rb
|