adops_report_scrapper 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c607980aba3786d27f887c7cf3e483e5ca9f9c7
|
4
|
+
data.tar.gz: 612447f3d4b4fd75d33829a526f50bd62f77d701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d343ae25f045bc41b47f1c63461292cc1693cbf4cad20b4f7de623a3ea96a6da084be319158062e11f63b5331a2f460eb1b183262782c2253bbf28e8e34dcd4
|
7
|
+
data.tar.gz: bc3e7b151ce2e26f6a17437e03f93ffb6a4f975de8019ad354f2b8a42b419bbf4526798c283b9b8d3b17072dbabb8c532b587542ed54a756db3bd776a7281dc6
|
data/CHANGELOG
CHANGED
@@ -1,51 +1,43 @@
|
|
1
1
|
require 'date'
|
2
2
|
require_relative 'base_client'
|
3
|
+
require 'rest-client'
|
3
4
|
|
4
5
|
class AdopsReportScrapper::RevcontentClient < AdopsReportScrapper::BaseClient
|
5
6
|
private
|
6
7
|
|
7
|
-
def
|
8
|
-
@client.visit 'https://www.revcontent.com/login'
|
9
|
-
@client.fill_in 'name', :with => @login
|
10
|
-
@client.fill_in 'password', :with => @secret
|
11
|
-
@client.click_button 'Sign In'
|
12
|
-
begin
|
13
|
-
@client.find :xpath, '//*[contains(text(),"Widgets")]'
|
14
|
-
rescue Exception => e
|
15
|
-
raise e, 'Revcontent login error'
|
16
|
-
end
|
8
|
+
def init_client
|
17
9
|
end
|
18
10
|
|
19
|
-
def
|
20
|
-
@client.find(:xpath, '//*[contains(text(),"Widgets")]').click
|
21
|
-
@client.find(:css, '.fa.fa-calendar').click
|
22
|
-
@client.find(:xpath, '//*[text()="Yesterday"]').click
|
23
|
-
@data = []
|
24
|
-
%w(desktoplg desktop tablet phone unknown).each do |device|
|
25
|
-
request_report(device)
|
26
|
-
extract_data_from_report(device)
|
27
|
-
end
|
11
|
+
def before_quit_with_error
|
28
12
|
end
|
29
13
|
|
30
|
-
def
|
31
|
-
@
|
32
|
-
|
33
|
-
|
34
|
-
@client.check device
|
35
|
-
end
|
14
|
+
def scrap
|
15
|
+
date_str = @date.strftime('%Y-%m-%d')
|
16
|
+
|
17
|
+
headers = { cache_control: 'no-cache' }
|
36
18
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
19
|
+
response = RestClient.post 'https://api.revcontent.io/oauth/token', { grant_type: 'client_credentials', client_id: @login, client_secret: @secret }, headers
|
20
|
+
data = JSON.parse response
|
21
|
+
token = data['access_token']
|
22
|
+
|
23
|
+
headers = { authorization: "Bearer #{token}", content_type: :json, cache_control: 'no-cache' }
|
24
|
+
|
25
|
+
data = []
|
26
|
+
|
27
|
+
%w(desktoplg desktop tablet mobile unknown).each do |device|
|
28
|
+
response = RestClient.get "https://api.revcontent.io/stats/api/v1.0/widgets?date_from=#{date_str}&date_to=#{date_str}&device=#{device}", headers
|
29
|
+
_data = JSON.parse response
|
30
|
+
_data = _data['data']
|
31
|
+
_data.each { |datum| datum['device'] = device }
|
32
|
+
data += _data
|
45
33
|
end
|
46
|
-
|
47
|
-
|
34
|
+
|
35
|
+
header = data[0].keys
|
36
|
+
@data = [header]
|
37
|
+
@data += data.map do |datum|
|
38
|
+
header.map { |key| datum[key] }
|
48
39
|
end
|
49
|
-
|
40
|
+
|
41
|
+
byebug
|
50
42
|
end
|
51
43
|
end
|
@@ -6,14 +6,12 @@ class AdopsReportScrapper::SpringserveClient < AdopsReportScrapper::BaseClient
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def init_client
|
9
|
-
end
|
10
|
-
|
11
|
-
def before_quit_with_error
|
12
9
|
fail 'please specify springserve account_id' unless @options['account_id']
|
13
10
|
@account_id = @options['account_id']
|
14
11
|
end
|
15
12
|
|
16
|
-
|
13
|
+
def before_quit_with_error
|
14
|
+
end
|
17
15
|
|
18
16
|
def scrap
|
19
17
|
date_str = @date.strftime('%Y-%m-%d')
|
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.2.
|
4
|
+
version: 0.2.41
|
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-11-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|