portal_scraper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/portal_scraper.rb +2 -0
- data/lib/portal_scraper/accounts/client.rb +20 -9
- data/lib/portal_scraper/bad_login_url.rb +6 -0
- data/lib/portal_scraper/bad_root_url.rb +6 -0
- data/lib/portal_scraper/portal_scraper_error.rb +4 -0
- data/lib/portal_scraper/version.rb +3 -4
- data/portal-scraper.gemspec +4 -2
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c17340a2ba668c837521fc740a1b2f6f845e79f689121e351c0a46d3929de5ab
|
4
|
+
data.tar.gz: a9e36eea49ee51e7d0128f9cc706839983ef9dcafd8e584823527725c660e1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b188d4e98c4e8cf0cedc6e474cdaae9cb7de80f40e96776f94fbb2aff476bd2bb0a4b44aae497b29481104e80d139137adf76e19133a45c1c76a370c39075970
|
7
|
+
data.tar.gz: b711ef1ff9de12d9c51460e7df2e8b71717bf11154bc31d84fb960a17f587606b1ffde83080caa94cd172eac3065a9acde01f5e0c951877c5aa477b85b29f0c6
|
data/lib/portal_scraper.rb
CHANGED
@@ -3,27 +3,38 @@ require 'mechanize'
|
|
3
3
|
module PortalScraper
|
4
4
|
module Accounts
|
5
5
|
class Client
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :_app_id, :_secret
|
7
7
|
|
8
8
|
def initialize(app_id = nil, secret = nil)
|
9
|
-
|
10
|
-
|
9
|
+
_app_id = app_id || config.app_id
|
10
|
+
_secret = secret || config.secret
|
11
|
+
raise BadRootUrl unless config.root_url =~ URI::regexp
|
12
|
+
end
|
13
|
+
|
14
|
+
def try_form_fields(form, fields, value)
|
15
|
+
fields.each do |field|
|
16
|
+
if form.respond_to?("#{field}=")
|
17
|
+
form.send("#{}=", value)
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
11
21
|
end
|
12
22
|
|
13
23
|
def login
|
24
|
+
raise BadLoginUrl if config.login_url.nil?
|
14
25
|
app.get(url_for(config.login_url)) do |login_page|
|
15
|
-
login_page.form_with(name: /login/i)
|
16
|
-
|
17
|
-
|
18
|
-
|
26
|
+
form = login_page.form_with(name: /login/i) || login_page.forms[0]
|
27
|
+
try_form_fields(form, %i(username login), _app_id)
|
28
|
+
try_form_fields(form, %i(password secret), _secret)
|
29
|
+
form.submit
|
19
30
|
end
|
20
|
-
app.get(url_for(config.token_url))
|
31
|
+
app.get(url_for(config.token_url)) unless config.token_url.nil?
|
21
32
|
end
|
22
33
|
|
23
34
|
def get_accounts_balance
|
24
35
|
login
|
25
36
|
accounts_data = { accounts: [] }
|
26
|
-
results
|
37
|
+
results = app.post(url_for('/appRecherche.do'), { nom: '', prenom: '', chercher: 'Chercher' })
|
27
38
|
results.links_with(href: /appTiersDetail.do/).each do |link|
|
28
39
|
account = link.click
|
29
40
|
accounts_data[:accounts] << {
|
data/portal-scraper.gemspec
CHANGED
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency 'mechanize', '~> 2.7'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
28
|
-
spec.add_development_dependency 'bundler',
|
29
|
-
spec.add_development_dependency 'rake',
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'vcr'
|
31
|
+
spec.add_development_dependency 'webmock'
|
30
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portal_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Armand Mégrot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: Scrapping client for extranet portals.
|
70
98
|
email:
|
71
99
|
- armand.megrot@gmail.com
|
@@ -75,6 +103,9 @@ extra_rdoc_files: []
|
|
75
103
|
files:
|
76
104
|
- lib/portal_scraper.rb
|
77
105
|
- lib/portal_scraper/accounts/client.rb
|
106
|
+
- lib/portal_scraper/bad_login_url.rb
|
107
|
+
- lib/portal_scraper/bad_root_url.rb
|
108
|
+
- lib/portal_scraper/portal_scraper_error.rb
|
78
109
|
- lib/portal_scraper/version.rb
|
79
110
|
- portal-scraper.gemspec
|
80
111
|
homepage: https://github.com/cashbee-team/portal_scraper
|
@@ -97,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
128
|
version: '0'
|
98
129
|
requirements: []
|
99
130
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.7.8
|
101
132
|
signing_key:
|
102
133
|
specification_version: 4
|
103
134
|
summary: Ruby portal scraper
|