adops_report_scrapper 0.1.45 → 0.1.46
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/README.md +16 -4
- data/Rakefile +5 -0
- data/lib/adops_report_scrapper.rb +1 -0
- data/lib/adops_report_scrapper/imonomy_client.rb +63 -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: 275a3babb56c7deaada93d0b5114ee6d03d12613
|
4
|
+
data.tar.gz: 9acf06c49ebc3b0bb50a3be33933bdea1a5a69d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3649d81f5520ef417f05ecccead341985cd048244757ef690b16fdb2d55a50e8e1c9babdcbe50249b5cb266f8103f6249be174e66084cd2f32a6250cd987231
|
7
|
+
data.tar.gz: e4f2fc8a5bc7d919cb8481d664834457a1ef563b6da560ebb777c463b951512ec06dd3ff444660c7a6a212de1b33fe419fb5864a1be012a3f121c5d0d33302a5
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Adops_Report_Scrapper
|
2
2
|
|
3
|
-
Adops Report Scrapper is a collection of web
|
3
|
+
Adops Report Scrapper (I meant scraper :P) is a collection of web scrapers that can automatically extract the data from your ad server, ad networks, ad exchanges, and other ad partners. It is an open source alternative to [STAQ](http://www.staq.com/). Say good-bye to spreadsheet. At the moment, this gem only focus on getting the data in. It is up to you how you would aggregate the data into your pageview & dfp/ad server data set.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -30,11 +30,23 @@ AdopsReportScrapper.get_scrapper(:brightroll, 'login', 'secret', {}).get_data
|
|
30
30
|
# example: [["Watch", "Status", "Name", "ID", "CPM Floor", "Revenue", "eCPM", "Requests", "Responses", "Response Rate", "Impressions", "Impression Rate", "Fill Rate", "Viewable Rate", "Clicks", "CTR", "Mid Rate", "Completion Rate", "Companion Impressions", "Companion Clicks", "Companion CTR", "Created On", "Last Modified"], ["", "", "My Post RON CDN", "3863603", "$6.00", "$9.99", "$6.68", "14,951", "2,556", "17.10%", "1,496", "58.53%", "10.01%", "60.87%", "7", "0.47%", "51.80%", "45.05%", "0.00%", "0", "0.00%", "03/23/2015", "06/25/2016"], ["", "", "My Post 400x300", "3855941", "$6.00", "$0.04", "$6.07", "78", "37", "47.44%", "6", "16.22%", "7.69%", "0.00%", "0", "0.00%", "50.00%", "66.67%", "0.00%", "0", "0.00%", "12/20/2013", "06/24/2016"], ["", "", "My Post", "3860218", "$7.00", "$0.03", "$8.07", "26", "12", "46.15%", "4", "33.33%", "15.38%", "0.00%", "0", "0.00%", "125.00%", "125.00%", "0.00%", "0", "0.00%", "10/10/2014", "06/09/2016"], ["", "", "My Post 640x480", "3855297", "$7.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "11/25/2013", "06/28/2016"], ["", "", "My Post 300x250", "3855943", "$2.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "12/20/2013", "06/09/2016"], ["", "", "Mobile - iPhone web…e My Post NCT", "3856072", "$4.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "01/07/2014", "05/23/2016"], ["", "", "Mobile - Android we…- The My Post", "3856089", "$4.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "01/08/2014", "05/23/2016"], ["", "", "Mobile - iPad web -…e My Post NCT", "3856127", "$4.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "01/10/2014", "05/23/2016"], ["", "", "My Today 6836382", "3860216", "$7.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "10/10/2014", "06/29/2016"], ["", "", "My Herald", "3860220", "$6.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "10/10/2014", "06/09/2016"], ["", "", "My News", "3860222", "$7.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "10/10/2014", "06/29/2016"], ["", "", "My Blog", "3860224", "$5.00", "$0.00", "$0.00", "15", "7", "46.67%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "10/10/2014", "06/09/2016"], ["", "", "My Times 400x300", "3863146", "$7.00", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "03/02/2015", "06/29/2016"], ["", "", "My Post RON UK", "3863604", "$5.46", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "03/23/2015", "06/09/2016"], ["", "", "My Post RON AU", "3863906", "$4.43", "$0.00", "$0.00", "0", "0", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0", "0.00%", "0.00%", "0.00%", "0.00%", "0", "0.00%", "04/01/2015", "06/09/2016"]]
|
31
31
|
```
|
32
32
|
|
33
|
-
##
|
33
|
+
## Standalone Setup
|
34
34
|
|
35
|
-
|
35
|
+
You may also choose to run this in the standalone mode.
|
36
36
|
|
37
|
-
|
37
|
+
Clone the code `git clone https://github.com/StaymanHou/adops_report_scrapper.git`
|
38
|
+
|
39
|
+
Copy the configuration file `cp secret.sample.yml secret.yml`. And modify the credentials in the secret.yml accordingly.
|
40
|
+
|
41
|
+
Install the dependencies `bundle install`
|
42
|
+
|
43
|
+
Run the scraper `bundle exec rake <scraper_name> # e.g. bundle exec rake openx`. It will scrape yesterday's data, and save it as a CSV file in the `./tmp/` directory.
|
44
|
+
|
45
|
+
## Supported Scrapers
|
46
|
+
|
47
|
+
Check `lib/adops_report_scrapper` directory for implemented scrapers.
|
48
|
+
|
49
|
+
Check `secret.sample.yml` for expected args to be passed to each scraper.
|
38
50
|
|
39
51
|
## Development
|
40
52
|
|
data/Rakefile
CHANGED
@@ -161,6 +161,11 @@ task :undertone do
|
|
161
161
|
save_as_csv :undertone, :undertone
|
162
162
|
end
|
163
163
|
|
164
|
+
desc 'Collect imonomy data'
|
165
|
+
task :imonomy do
|
166
|
+
save_as_csv :imonomy, :imonomy
|
167
|
+
end
|
168
|
+
|
164
169
|
def date
|
165
170
|
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
166
171
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
|
4
|
+
# gcs sometimes doesn't update data in 24 hours
|
5
|
+
|
6
|
+
class AdopsReportScrapper::ImonomyClient < AdopsReportScrapper::BaseClient
|
7
|
+
def date_supported?(date = nil)
|
8
|
+
_date = date || @date
|
9
|
+
return true if _date >= Date.today - 7
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def login
|
16
|
+
@client.visit 'http://dashboard.imonomy.com/'
|
17
|
+
@client.fill_in 'Username', :with => @login
|
18
|
+
@client.fill_in 'Password', :with => @secret
|
19
|
+
@client.click_button 'Sign In'
|
20
|
+
begin
|
21
|
+
@client.find :xpath, '//*[text()="My Statistics"]'
|
22
|
+
rescue Exception => e
|
23
|
+
raise e, 'Imonomy login error'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def scrap
|
28
|
+
@data = []
|
29
|
+
return if @date == Date.today - 1 # imonomy never update revenues for in 1 day
|
30
|
+
request_report
|
31
|
+
extract_data_from_report
|
32
|
+
end
|
33
|
+
|
34
|
+
def request_report
|
35
|
+
@client.find(:xpath, '//*[text()="My Statistics"]').click
|
36
|
+
|
37
|
+
@client.find(:xpath, '//option[text()="Last 7 Days"]').select_option
|
38
|
+
@client.check 'Website'
|
39
|
+
@client.check 'Country'
|
40
|
+
@client.check 'Device'
|
41
|
+
|
42
|
+
@client.click_link 'Submit'
|
43
|
+
sleep 10
|
44
|
+
|
45
|
+
@client.find(:xpath, '//option[text()="100"]').select_option
|
46
|
+
end
|
47
|
+
|
48
|
+
def extract_data_from_report
|
49
|
+
until @client.find(:xpath, '//*[text()=">"]')[:disabled] == "disabled"
|
50
|
+
rows = @client.find_all :xpath, %Q{//table/tbody/tr[./td[text()="#{@date.strftime('%d.%m.%Y')}"]]}
|
51
|
+
rows = rows.to_a
|
52
|
+
if @data.count == 0
|
53
|
+
header = @client.find :xpath, '//table/thead/tr'
|
54
|
+
n_header = header.find_css('td,th').map { |td| td.visible_text }
|
55
|
+
@data << n_header
|
56
|
+
end
|
57
|
+
@data.concat rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } }
|
58
|
+
|
59
|
+
@client.find(:xpath, '//*[text()=">"]').click
|
60
|
+
sleep 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
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.46
|
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-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/adops_report_scrapper/criteo_client.rb
|
234
234
|
- lib/adops_report_scrapper/facebookaudience_client.rb
|
235
235
|
- lib/adops_report_scrapper/gcs_client.rb
|
236
|
+
- lib/adops_report_scrapper/imonomy_client.rb
|
236
237
|
- lib/adops_report_scrapper/littlethings_client.rb
|
237
238
|
- lib/adops_report_scrapper/liveintent_client.rb
|
238
239
|
- lib/adops_report_scrapper/marfeel_client.rb
|