adops_report_scrapper 0.1.52 → 0.1.53
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 +5 -0
- data/lib/adops_report_scrapper/imonomy_client.rb +0 -2
- data/lib/adops_report_scrapper/positivemobile_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 +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53dcb8d2f6564cdbe088c2328fbc083fd9569943
|
4
|
+
data.tar.gz: ad1d6f7925db7a8c1bcec00125d1fb982d802da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09ebadfdde3371c20e7f6d2b7af9a3c399f3d5cf77016fd890a12d406602c16ca765a8d9e03471b1dbbe4b63f8d6c35ac12cc36b20f457d77d6085f5d463ea99
|
7
|
+
data.tar.gz: 129d3e422282c08c39c7854619372228e281f85514a0e418b43cf4245e0704ef6020b26e583dd763932250c8390cd776cfa8dca9e65d95bba20de4310148311c
|
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -166,6 +166,11 @@ task :imonomy do
|
|
166
166
|
save_as_csv :imonomy, :imonomy
|
167
167
|
end
|
168
168
|
|
169
|
+
desc 'Collect positivemobile data'
|
170
|
+
task :positivemobile do
|
171
|
+
save_as_csv :positivemobile, :positivemobile
|
172
|
+
end
|
173
|
+
|
169
174
|
def date
|
170
175
|
@date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
|
171
176
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'date'
|
2
|
+
require_relative 'base_client'
|
3
|
+
|
4
|
+
class AdopsReportScrapper::PositivemobileClient < 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://rapidv.positivemobile.com/'
|
15
|
+
@client.fill_in 'Username', :with => @login
|
16
|
+
@client.fill_in 'Password', :with => @secret
|
17
|
+
@client.click_button 'Sign in'
|
18
|
+
begin
|
19
|
+
@client.find :xpath, '//*[text()="Reports"]'
|
20
|
+
rescue Exception => e
|
21
|
+
raise e, 'Positivemobile login error'
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
cookies = @client.driver.cookies
|
26
|
+
@client = HTTPClient.new
|
27
|
+
@client.cookie_manager.cookies = cookies.values.map do |cookie|
|
28
|
+
cookie = cookie.instance_variable_get(:@attributes)
|
29
|
+
HTTP::Cookie.new cookie
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def scrap
|
34
|
+
request_report
|
35
|
+
extract_data_from_report
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_report
|
39
|
+
date_str = @date.strftime('%Y-%m-%d')
|
40
|
+
|
41
|
+
header = {
|
42
|
+
Accept: 'Accept:application/json, text/plain, */*',
|
43
|
+
Origin: 'https://rapidv.positivemobile.com',
|
44
|
+
Referer: ':https//rapidv.positivemobile.com/reports',
|
45
|
+
'User-Agent': 'Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1',
|
46
|
+
'Content-Type': 'application/json',
|
47
|
+
}
|
48
|
+
|
49
|
+
body = {
|
50
|
+
dimensions: ['tagName', 'udc'],
|
51
|
+
filters: [],
|
52
|
+
from: "#{date_str}T00:00:00.000Z",
|
53
|
+
metrics: ['imp', 'revenue_publisher_cpm', 'dspimpv'],
|
54
|
+
timeFrame: 'Custom',
|
55
|
+
timeLevel: 'Daily',
|
56
|
+
timeZone: 'America/New_York',
|
57
|
+
to: "#{date_str}T00:00:00.000Z",
|
58
|
+
type: 'Supply'
|
59
|
+
}.to_json
|
60
|
+
|
61
|
+
@response = @client.post('https://rapidv.positivemobile.com/api/reports/run', header: header, body: body )
|
62
|
+
end
|
63
|
+
|
64
|
+
def extract_data_from_report
|
65
|
+
rows = JSON.parse @response.body
|
66
|
+
keys = rows.first.keys
|
67
|
+
@data = [keys]
|
68
|
+
@data += rows.map(&:values)
|
69
|
+
end
|
70
|
+
end
|
data/secret.sample.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stayman Hou
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- lib/adops_report_scrapper/nativo_client.rb
|
241
241
|
- lib/adops_report_scrapper/netseer_client.rb
|
242
242
|
- lib/adops_report_scrapper/openx_client.rb
|
243
|
+
- lib/adops_report_scrapper/positivemobile_client.rb
|
243
244
|
- lib/adops_report_scrapper/revcontent_client.rb
|
244
245
|
- lib/adops_report_scrapper/rhythmone_client.rb
|
245
246
|
- lib/adops_report_scrapper/rubicon_client.rb
|