adops_report_scrapper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ed4888eb209682c4179f2320fc0c76dcc9bb266
|
4
|
+
data.tar.gz: b4ec13ef9772b23179c18dab0863607387bacb33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bcc8a0ac2d9b7c01232a5663cd97e0eb06cdd39d1f7d767faa6a9ed6d5e75c30572dfc0abc9cfa2b04362e299521f60092d7ef4d3a4b28aaf392ee8d96bea25
|
7
|
+
data.tar.gz: c8056cda55d69c3993de465e19021f948bd81b5ff859ede4564f4322fcc35b9aa638da47d57b67c6a302e92869554fe3978daba32fffaad94dbe94a827250658
|
data/Rakefile
CHANGED
@@ -126,12 +126,16 @@ task :facebookaudience do
|
|
126
126
|
save_as_csv :facebookaudience, :facebookaudience
|
127
127
|
end
|
128
128
|
|
129
|
+
def date
|
130
|
+
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
131
|
+
end
|
132
|
+
|
129
133
|
def get_yesterdays_file_path(adnetwork)
|
130
|
-
"tmp/#{
|
134
|
+
"tmp/#{@date}/#{adnetwork}.csv"
|
131
135
|
end
|
132
136
|
|
133
137
|
def write_csv(adnet, data)
|
134
|
-
Dir.mkdir "tmp/#{
|
138
|
+
Dir.mkdir "tmp/#{@date}" unless Dir.exists? "tmp/#{@date}"
|
135
139
|
CSV.open(get_yesterdays_file_path(adnet), 'w') do |csv|
|
136
140
|
data.each do |row|
|
137
141
|
csv << row
|
@@ -146,7 +150,6 @@ def save_as_csv(adnet, scrapper) # adnet and scrapper are both sym
|
|
146
150
|
end
|
147
151
|
puts "========== working on #{adnet}"
|
148
152
|
cred = YAML.load_file('secret.yml')[adnet.to_s]
|
149
|
-
data = AdopsReportScrapper.get_scrapper(adnet, cred['login'], cred['secret'], cred['options']).get_data
|
150
|
-
byebug
|
153
|
+
data = AdopsReportScrapper.get_scrapper(adnet, cred['login'], cred['secret'], cred['options']).get_data(date)
|
151
154
|
write_csv(adnet, data)
|
152
155
|
end
|
@@ -3,6 +3,12 @@ require_relative 'base_client'
|
|
3
3
|
require 'open-uri'
|
4
4
|
|
5
5
|
class AdopsReportScrapper::BrowsiClient < AdopsReportScrapper::BaseClient
|
6
|
+
def date_supported?(date = nil)
|
7
|
+
_date = date || @date
|
8
|
+
return true if _date >= Date.today - 7
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
6
12
|
private
|
7
13
|
|
8
14
|
def login
|
@@ -4,6 +4,12 @@ require_relative 'base_client'
|
|
4
4
|
# gcs sometimes doesn't update data in 24 hours
|
5
5
|
|
6
6
|
class AdopsReportScrapper::GcsClient < 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
|
+
|
7
13
|
private
|
8
14
|
|
9
15
|
def login
|