portal_scraper 2.0.3 → 2.1.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '009002ad1b898fbfd1b7aa934da6e15acf6c74b0a065d9c7c95060433ff3eff8'
|
4
|
+
data.tar.gz: 7775cc6cb2ed570c50b25783e399a0008be103196f7b70f749b4affb35773012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1040fc3657d32bb490a38b7896016b009c53c69da99988568adf9aafb01fcc82b8c406cd18d4ac5dab6d3904ebffd08792cf82bf50b19b5a810e254517e3e3c6
|
7
|
+
data.tar.gz: 62fe9b8a3110ea2944849dfa58927556e43511b81d2ed1529fa93235cd95ef636cfb86848d6c813567a60ab8266bd53a73fd6051e91b11c67958022b78d9c808
|
@@ -9,6 +9,7 @@ module PortalScraper
|
|
9
9
|
attr_accessor :app_id, :secret
|
10
10
|
|
11
11
|
CODE_TO_COUNTRY_MAPPING = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'code_to_country.json')))
|
12
|
+
IS_POSTAL_CODE_DOM = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'is_postal_code_dom.json')))
|
12
13
|
MINIMUM_AMOUNT = 10
|
13
14
|
|
14
15
|
def initialize(app_id = nil, secret = nil)
|
@@ -24,8 +25,8 @@ module PortalScraper
|
|
24
25
|
user_page = app.post(url_for('/appRecherche.do'), { nom: '', prenom: '', chercher: 'Chercher' })
|
25
26
|
loop do
|
26
27
|
user_page.links_with(href: /appTiersDetail.do/).each do |link|
|
27
|
-
account
|
28
|
-
selected_link
|
28
|
+
account = link.click
|
29
|
+
selected_link = nil
|
29
30
|
opened_on, balance = nil, 0.to_d
|
30
31
|
|
31
32
|
account.links_with(css: 'table#contrat td a').each do |account_link|
|
@@ -36,8 +37,8 @@ module PortalScraper
|
|
36
37
|
next unless opened_on.nil? || opened_on < row_date
|
37
38
|
|
38
39
|
selected_link = account_link
|
39
|
-
opened_on
|
40
|
-
balance
|
40
|
+
opened_on = row_date
|
41
|
+
balance = parse_number(row.at('td[5]'))
|
41
42
|
end
|
42
43
|
|
43
44
|
next unless selected_link
|
@@ -68,7 +69,7 @@ module PortalScraper
|
|
68
69
|
form['commune'] = user[:codeInsee]
|
69
70
|
form['libCommune'] = user[:ville]
|
70
71
|
else
|
71
|
-
fill_commune(app, form, user[:codePostal], parse_city_name(user[:ville])
|
72
|
+
fill_commune(app, form, user[:codePostal], parse_city_name(user[:ville]))
|
72
73
|
end
|
73
74
|
fill_address(form, user[:numeroVoie])
|
74
75
|
fill_birth_place(form, user[:paysNaissance])
|
@@ -85,6 +86,8 @@ module PortalScraper
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
nil
|
89
|
+
rescue => e
|
90
|
+
{ error: e.message }
|
88
91
|
end
|
89
92
|
|
90
93
|
def create_proposition(client_ref)
|
@@ -148,14 +151,15 @@ module PortalScraper
|
|
148
151
|
end
|
149
152
|
end
|
150
153
|
|
151
|
-
def fill_commune(app, form, postal_code, city
|
154
|
+
def fill_commune(app, form, postal_code, city)
|
152
155
|
app.post(url_for('/tiersCommunes.do'), { codPos: postal_code }).tap do |mappings|
|
153
|
-
cities
|
154
|
-
matched_city
|
156
|
+
cities = mappings.search('td.t').map { |c| { code: c.parent.search('a.PL_LST').text.strip, name: c.text.strip } }
|
157
|
+
matched_city = cities.find(-> { cities.first }) { |c| c[:name].include?(city) }
|
158
|
+
raise "City '#{city}' and postcode '#{postal_code}' not found" unless matched_city
|
155
159
|
form['commune'] = matched_city[:code]
|
156
160
|
form['libCommune'] = matched_city[:name]
|
157
161
|
end
|
158
|
-
form['territoireRes'] =
|
162
|
+
form['territoireRes'] = IS_POSTAL_CODE_DOM.dig(postal_code[0..2], 'category') || 0
|
159
163
|
end
|
160
164
|
|
161
165
|
def fill_address(form, address)
|
@@ -0,0 +1 @@
|
|
1
|
+
{"971":{"name":"GUADELOUPE","category":1},"972":{"name":"MARTINIQUE","category":1},"973":{"name":"GUYANE FRANCAISE","category":1},"974":{"name":"REUNION","category":1}}
|
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.
|
4
|
+
version: 2.1.3
|
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-
|
12
|
+
date: 2020-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/portal_scraper.rb
|
149
149
|
- lib/portal_scraper/accounts/client.rb
|
150
150
|
- lib/portal_scraper/accounts/code_to_country.json
|
151
|
+
- lib/portal_scraper/accounts/is_postal_code_dom.json
|
151
152
|
- lib/portal_scraper/bad_login_url.rb
|
152
153
|
- lib/portal_scraper/bad_root_url.rb
|
153
154
|
- lib/portal_scraper/parsing_helper.rb
|