takuhai_status 1.8.9 → 1.8.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takuhai_status/sagawa.rb +21 -19
- data/lib/takuhai_status/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36f48bde6e33990a902c142f1192bda4863273d829531f7bc74056970885efd8
|
4
|
+
data.tar.gz: 3ad6b113e5fab07e35116336cebabdf399f8193508f526f33cb626272969ced7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa31f2d5002fbc425de03b4d5b918013752516a18e54a3ac23eca4d274856cefe5b08495ee610bf6677b32d2bad0b4484db38d10f217db4b065499e87c1a8a37
|
7
|
+
data.tar.gz: 3c7c6dd8805774d67ca45cb8ae52075d52f33aee7b40eea25f19d10b4ec07b7d628cc52e32098e7580683e37edc7fb981c3dcec16ae3f4bea4c6faf47836cac1
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'nokogiri'
|
1
|
+
require 'mechanize'
|
3
2
|
|
4
3
|
module TakuhaiStatus
|
5
4
|
class Sagawa
|
@@ -13,31 +12,34 @@ module TakuhaiStatus
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def finish?
|
16
|
-
return !!(@state =~
|
15
|
+
return !!(@state =~ /営業所へお問い合わせください。|配達は終了致しました。$|^配達完了|引渡完了/)
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
def check
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
agent = Mechanize.new
|
21
|
+
page = agent.get('https://k2k.sagawa-exp.co.jp/p/sagawa/web/okurijoinput.jsp')
|
22
|
+
form = page.form_with('main')
|
23
|
+
form['main:no1'] = @key
|
24
|
+
button = form.button_with('main:toiStart')
|
25
|
+
result = agent.submit(form, button)
|
24
26
|
|
25
27
|
begin
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
row = result.css('#detail1 tr')
|
29
|
+
cells = row[row.size - 1].css('td')
|
30
|
+
if cells.size == 3 #has detail
|
31
|
+
state = "#{cells[0].text.strip[1,100]} [#{cells[2].text.strip}]"
|
32
|
+
time = Time.parse(cells[1].text.strip) rescue Time.now
|
33
|
+
else # finished?
|
34
|
+
state = cells[0].text.strip
|
32
35
|
time = Time.now
|
33
|
-
state = doc.css('.table_okurijo_detail').first.css('tr').last.css('td').text.strip
|
34
|
-
if state =~ /恐れ入りますが、お問い合せ送り状NOをお確かめください。|お荷物データが登録されておりません。/
|
35
|
-
raise NotMyKey.new('invalid key')
|
36
|
-
end
|
37
|
-
return time, state
|
38
|
-
rescue NoMethodError
|
39
|
-
raise NotMyKey.new('invalid response')
|
40
36
|
end
|
37
|
+
if state =~ /恐れ入りますが、お問い合せ送り状NOをお確かめください。|お荷物データが登録されておりません。/
|
38
|
+
raise NotMyKey.new('invalid key')
|
39
|
+
end
|
40
|
+
return time, state
|
41
|
+
rescue NoMethodError
|
42
|
+
raise NotMyKey.new('invalid response')
|
41
43
|
rescue ArgumentError
|
42
44
|
return Time.now, ''
|
43
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takuhai_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.0.
|
183
|
+
rubygems_version: 3.0.3
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: get delivery status of Takuhai-bin in Japan
|