portal_scraper 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/portal_scraper/accounts/client.rb +35 -18
- data/lib/portal_scraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f511d4ae5d6568df6bc6960907a0964ecfb6c8f0c8d5850b5ad757a0ed35039
|
4
|
+
data.tar.gz: 5edb4fdbd33676d7b03623a86815b0b865fd214d85e4cd6e34e7fe42fa67204b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df684726b58e1d8da72af7abd8b0395d36bc403f8d045ef0abbf628a8eee0aeebaa13f13ecbc9e80b9ff1dd088695eec92470dac707d5e5977dab1961196234
|
7
|
+
data.tar.gz: d93c42d08e8f39ddacf8828060e91324f0ad1b42f1f131b381d43ba693bbba8d05c3d82e1c669736fc153d087b9f648ba1af8fab7936be25c70ee10d811c2708
|
@@ -21,35 +21,35 @@ module PortalScraper
|
|
21
21
|
login
|
22
22
|
accounts_data = { accounts: [] }
|
23
23
|
|
24
|
-
|
24
|
+
user_page = app.post(url_for('/appRecherche.do'), { nom: '', prenom: '', chercher: 'Chercher' })
|
25
25
|
loop do
|
26
|
-
|
27
|
-
account
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
debit: parse_number(row.search('td[4]')),
|
37
|
-
credit: parse_number(row.search('td[5]')),
|
38
|
-
}
|
26
|
+
user_page.links_with(href: /appTiersDetail.do/).each do |link|
|
27
|
+
account = link.click
|
28
|
+
selected_row = nil
|
29
|
+
selected_row_date = nil
|
30
|
+
|
31
|
+
account.links_with(css: 'table#contrat td a').each do |row|
|
32
|
+
row_date = parse_date(row.node.ancestors('tr').at('td[2]'))&.to_date
|
33
|
+
if selected_row_date.nil? || selected_row_date < row_date
|
34
|
+
selected_row_date = row_date
|
35
|
+
selected_row = row
|
39
36
|
end
|
40
37
|
end
|
38
|
+
|
39
|
+
transfers = scrap_transfers(selected_row)
|
40
|
+
balance = selected_row&.node&.ancestors('tr')&.at('td[4]')
|
41
41
|
accounts_data[:accounts] << {
|
42
42
|
client_ref: find_table_value(account, 'Identifiant tiers'),
|
43
|
-
balance:
|
44
|
-
opened_on: parse_dates(account.search('table#contrat td'))&.max,
|
43
|
+
balance: balance.nil? ? "0".to_d : parse_number(balance),
|
44
|
+
opened_on: selected_row_date.nil? ? parse_dates(account.search('table#contrat td'))&.max : selected_row_date.to_s,
|
45
45
|
transfers: transfers,
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
-
break unless
|
49
|
+
break unless user_page.search('.pg_next').present?
|
50
50
|
# Need to fetch the first page as you cannot navigate from client back to research page
|
51
51
|
app.post(url_for('/appRecherche.do'), { nom: '', prenom: '', chercher: 'Chercher' })
|
52
|
-
|
52
|
+
user_page = app.get(user_page.search('a.pg_next').first['href'])
|
53
53
|
end
|
54
54
|
accounts_data
|
55
55
|
end
|
@@ -174,6 +174,23 @@ module PortalScraper
|
|
174
174
|
def config
|
175
175
|
PortalScraper.config
|
176
176
|
end
|
177
|
+
|
178
|
+
def scrap_transfers(selected_row)
|
179
|
+
transfers = []
|
180
|
+
transfers_page = selected_row&.click
|
181
|
+
if transfers_page
|
182
|
+
transfers_page.search('table#operation tbody tr').each do |row|
|
183
|
+
transfers << {
|
184
|
+
operation_date: parse_date(row.search('td[1]')),
|
185
|
+
nature: row.search('td[2]').text.strip.gsub(/[\n,\t,'']/, ''),
|
186
|
+
value_date: parse_date(row.search('td[3]')),
|
187
|
+
debit: parse_number(row.search('td[4]')),
|
188
|
+
credit: parse_number(row.search('td[5]')),
|
189
|
+
}
|
190
|
+
end
|
191
|
+
end
|
192
|
+
transfers
|
193
|
+
end
|
177
194
|
end
|
178
195
|
end
|
179
196
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portal_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Armand Mégrot
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-01-
|
12
|
+
date: 2020-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|