portal_scraper 1.1.0 → 1.1.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 +7 -7
- data/lib/portal_scraper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccad098b23566f5d701390d2b26ca64f1aaa1683d5f23c11d41621e280b49d13
|
4
|
+
data.tar.gz: e6a8f24944f3360d741a22a7b2d4698a20a3c6412795a8349037759c803f6bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ca0e84ec2ea07966ee28565a55f1973fd4140433a0da55968f4647970b8861d216acd00d088f46f0d649b38fa9f18751eb1d5a7f44e0ce94b3c914cdc1c8e2
|
7
|
+
data.tar.gz: 750a7dbe9f3384786fbd1a46a8f38c30a0182f3ec27726b32e4efd9dccdbc14e708b21a9f6a9bac0432a7723237c6a2d632962a9024d919945a30d9c674e23ef
|
@@ -3,18 +3,18 @@ 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
11
|
raise BadRootUrl unless config.root_url =~ URI::regexp
|
12
12
|
end
|
13
13
|
|
14
14
|
def try_form_fields(form, fields, value)
|
15
15
|
fields.each do |field|
|
16
|
-
if form.
|
17
|
-
form
|
16
|
+
if form.has_field?(field)
|
17
|
+
form[field] = value
|
18
18
|
break
|
19
19
|
end
|
20
20
|
end
|
@@ -24,8 +24,8 @@ module PortalScraper
|
|
24
24
|
raise BadLoginUrl if config.login_url.nil?
|
25
25
|
app.get(url_for(config.login_url)) do |login_page|
|
26
26
|
form = login_page.form_with(name: /login/i) || login_page.forms[0]
|
27
|
-
try_form_fields(form, %
|
28
|
-
try_form_fields(form, %
|
27
|
+
try_form_fields(form, %w(username login), app_id)
|
28
|
+
try_form_fields(form, %w(password secret), secret)
|
29
29
|
form.submit
|
30
30
|
end
|
31
31
|
app.get(url_for(config.token_url)) unless config.token_url.nil?
|