adops_report_scrapper 0.1.4 → 0.1.5

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: 10e30e07782bffd3f6b6e2dc3a5774f8f91196b3
4
- data.tar.gz: 748a6a341e21f648cd5b0291ded6d1e6c3dad686
3
+ metadata.gz: 90ddebdbcf3cfd0c810e901e848db5745beb16bf
4
+ data.tar.gz: 9e9974b8b6c28c3cebce1a9f7e104ff6bf714e1d
5
5
  SHA512:
6
- metadata.gz: 2e9a718dc2bb16862cba915583bacc1c369a6835812f0123516065f83d447d16d06bf2d4fa40c53e39da0ac4efc76a2e3f8dada1d36c053a1c3d388976c775b2
7
- data.tar.gz: 2d851c270ec6e056aa27cd69098817b490964266fb403d0b9487b3a7c2da1dff7a8cac097136937b0051399f99970a4e67a3116e06de137a4ccd3a4624002735
6
+ metadata.gz: ca85fd4ca169052d8c34f865ea311c6c1c804cb6820c56637b40eff542c6086c73296fe5147ed0b7367ddbcd74777e8c587990b7f76f932199d7586a8515a4e8
7
+ data.tar.gz: 1874fbb0593d472c3f24339966008471cf84bed45e78b6b53c13e666ff56fa59df7749fd2210c4bb78aefae5eda5488f68089acddaf59708013ed98e0800b162
@@ -32,30 +32,38 @@ class AdopsReportScrapper::TripleliftClient < AdopsReportScrapper::BaseClient
32
32
  index = -1 - @publishers.count(publisher)
33
33
  sleep 1
34
34
  @client.find_all(:xpath, "//*[text()=\"#{publisher}\"]")[index].click
35
- @client.find(:xpath, '//*[text()="Reporting"]').click
36
- sleep 2
35
+ 10.times do
36
+ @client.find(:xpath, '//*[text()="Reporting"]').click
37
+ sleep 2
37
38
 
38
- return if @client.find_all(:xpath, '//*[text()="No data available for selected date range"]').count > 0
39
+ return if @client.find_all(:xpath, '//*[text()="No data available for selected date range"]').count > 0
39
40
 
40
- @client.find(:xpath, '//*[@model="startDate"]//input').set @date_str
41
- sleep 1
42
- @client.find(:xpath, '//*[@model="endDate"]//input').set @date_str
43
- sleep 1
44
- @client.find(:xpath, '//button[../../div[contains(text(),"Group by")]]').click
45
- @client.find(:xpath, '//*[text()="Date and Placement"]').click
46
- wait_for_spin
41
+ @client.find(:xpath, '//*[@model="startDate"]//input').set @date_str
42
+ sleep 1
43
+ @client.find(:xpath, '//*[@model="endDate"]//input').set @date_str
44
+ sleep 1
45
+ @client.find(:xpath, '//button[../../div[contains(text(),"Group by")]]').click
46
+ @client.find(:xpath, '//*[text()="Date and Placement"]').click
47
+ wait_for_spin
47
48
 
48
- return if @client.find_all(:xpath, '//*[text()="No data available for selected date range"]').count > 0
49
+ return if @client.find_all(:xpath, '//*[text()="No data available for selected date range"]').count > 0
49
50
 
50
- rows = @client.find_all :xpath, '//table/*/tr'
51
- rows = rows.to_a
52
- rows.shift
53
- header = rows.shift
54
- if @data.count == 0
55
- n_header = header.find_css('td,th').map { |td| td.visible_text }
56
- @data << n_header
51
+ rows = @client.find_all :xpath, '//table/*/tr'
52
+ rows = rows.to_a
53
+ rows.shift
54
+ header = rows.shift
55
+ n_data = rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } }
56
+ if n_data[-1][1].empty?
57
+ @client.evaluate_script 'window.location.reload()'
58
+ next
59
+ end
60
+ if @data.count == 0
61
+ n_header = header.find_css('td,th').map { |td| td.visible_text }
62
+ @data << n_header
63
+ end
64
+ @data += n_data
65
+ break
57
66
  end
58
- @data += rows.map { |tr| tr.find_css('td,th').map { |td| td.visible_text } }
59
67
  end
60
68
 
61
69
  def wait_for_spin
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
4
+ version: 0.1.5
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-08-17 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient