amazon_seller_central 0.2.16 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +25 -4
- data/VERSION +1 -1
- data/amazon_seller_central.gemspec +5 -5
- data/lib/amazon_seller_central/inventory_page.rb +6 -4
- data/lib/amazon_seller_central/mechanizer.rb +21 -9
- metadata +32 -32
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,6 +4,8 @@ GEM
|
|
4
4
|
archive-tar-minitar (0.5.2)
|
5
5
|
columnize (0.3.5)
|
6
6
|
diff-lcs (1.1.2)
|
7
|
+
domain_name (0.5.13)
|
8
|
+
unf (>= 0.0.5, < 1.0.0)
|
7
9
|
faker (0.9.5)
|
8
10
|
i18n (~> 0.4)
|
9
11
|
fakeweb (1.3.0)
|
@@ -13,6 +15,8 @@ GEM
|
|
13
15
|
thor (~> 0.14.6)
|
14
16
|
guard-rspec (0.4.0)
|
15
17
|
guard (>= 0.4.0)
|
18
|
+
http-cookie (1.0.1)
|
19
|
+
domain_name (~> 0.5)
|
16
20
|
i18n (0.6.0)
|
17
21
|
jeweler (1.8.4)
|
18
22
|
bundler (~> 1.0)
|
@@ -23,9 +27,22 @@ GEM
|
|
23
27
|
libnotify (0.5.6)
|
24
28
|
linecache19 (0.5.12)
|
25
29
|
ruby_core_source (>= 0.1.4)
|
26
|
-
mechanize (
|
27
|
-
|
28
|
-
|
30
|
+
mechanize (2.7.2)
|
31
|
+
domain_name (~> 0.5, >= 0.5.1)
|
32
|
+
http-cookie (~> 1.0.0)
|
33
|
+
mime-types (~> 1.17, >= 1.17.2)
|
34
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
35
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
36
|
+
nokogiri (~> 1.4)
|
37
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
38
|
+
webrobots (>= 0.0.9, < 0.2)
|
39
|
+
mime-types (1.25)
|
40
|
+
mini_portile (0.5.1)
|
41
|
+
net-http-digest_auth (1.4)
|
42
|
+
net-http-persistent (2.9)
|
43
|
+
nokogiri (1.6.0)
|
44
|
+
mini_portile (~> 0.5.0)
|
45
|
+
ntlm-http (0.1.1)
|
29
46
|
rake (10.0.4)
|
30
47
|
rb-inotify (0.8.5)
|
31
48
|
ffi (>= 0.5.0)
|
@@ -51,6 +68,10 @@ GEM
|
|
51
68
|
ruby_core_source (0.1.5)
|
52
69
|
archive-tar-minitar (>= 0.5.2)
|
53
70
|
thor (0.14.6)
|
71
|
+
unf (0.1.2)
|
72
|
+
unf_ext
|
73
|
+
unf_ext (0.0.6)
|
74
|
+
webrobots (0.1.1)
|
54
75
|
yard (0.7.2)
|
55
76
|
|
56
77
|
PLATFORMS
|
@@ -65,7 +86,7 @@ DEPENDENCIES
|
|
65
86
|
guard-rspec
|
66
87
|
jeweler
|
67
88
|
libnotify
|
68
|
-
mechanize (>=
|
89
|
+
mechanize (>= 2.0.0)
|
69
90
|
rb-inotify (>= 0.8.5)
|
70
91
|
rcov
|
71
92
|
rspec (~> 2.3.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "amazon_seller_central"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["optoro"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-09-03"
|
13
13
|
s.description = "This gem is intended to wrap Amazon's SellerCentral pages with a Ruby API. Currently this gem supports accessing buyer feedback only."
|
14
14
|
s.email = "dev@optoro.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -86,7 +86,7 @@ Gem::Specification.new do |s|
|
|
86
86
|
s.specification_version = 3
|
87
87
|
|
88
88
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
89
|
-
s.add_runtime_dependency(%q<mechanize>, [">=
|
89
|
+
s.add_runtime_dependency(%q<mechanize>, [">= 2.0.0"])
|
90
90
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
91
91
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
92
92
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
@@ -101,7 +101,7 @@ Gem::Specification.new do |s|
|
|
101
101
|
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
102
102
|
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
103
103
|
else
|
104
|
-
s.add_dependency(%q<mechanize>, [">=
|
104
|
+
s.add_dependency(%q<mechanize>, [">= 2.0.0"])
|
105
105
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
106
106
|
s.add_dependency(%q<bundler>, [">= 0"])
|
107
107
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -117,7 +117,7 @@ Gem::Specification.new do |s|
|
|
117
117
|
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
118
118
|
end
|
119
119
|
else
|
120
|
-
s.add_dependency(%q<mechanize>, [">=
|
120
|
+
s.add_dependency(%q<mechanize>, [">= 2.0.0"])
|
121
121
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
122
122
|
s.add_dependency(%q<bundler>, [">= 0"])
|
123
123
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -74,9 +74,11 @@ module AmazonSellerCentral
|
|
74
74
|
# 6 - product name
|
75
75
|
# 7 - date created
|
76
76
|
# 8 - qty
|
77
|
-
# 9 -
|
78
|
-
# 10 -
|
77
|
+
# 9 - your price
|
78
|
+
# 10 - condition
|
79
79
|
# 11 - low price
|
80
|
+
# 12 - buy-box price
|
81
|
+
# 13 - fulfilled by
|
80
82
|
def listing_row_to_object(row)
|
81
83
|
l = Listing.new
|
82
84
|
row.css('td').each_with_index do |td, i|
|
@@ -95,9 +97,9 @@ module AmazonSellerCentral
|
|
95
97
|
when 8
|
96
98
|
l.quantity = (inputs = td.css('input')).any? ? inputs.first['value'].to_i : txt.to_i
|
97
99
|
when 9
|
98
|
-
l.condition = txt
|
99
|
-
when 10
|
100
100
|
l.price = get_price(td)
|
101
|
+
when 10
|
102
|
+
l.condition = txt
|
101
103
|
when 11
|
102
104
|
l.low_price = get_low_price(td)
|
103
105
|
when 3
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'mechanize'
|
2
2
|
module AmazonSellerCentral
|
3
3
|
class Mechanizer
|
4
|
-
MASQUERADE_AGENTS = ['Mac Safari', 'Mac FireFox', 'Linux Firefox']
|
4
|
+
MASQUERADE_AGENTS = ['Mac Safari', 'Mac FireFox', 'Linux Firefox', 'Windows IE 9']
|
5
5
|
|
6
6
|
attr_reader :agent
|
7
7
|
|
8
|
+
def initialize
|
9
|
+
@logged_in = false
|
10
|
+
end
|
11
|
+
|
8
12
|
def login_email
|
9
13
|
AmazonSellerCentral.configuration.login_email
|
10
14
|
end
|
@@ -22,19 +26,25 @@ module AmazonSellerCentral
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def login_to_seller_central
|
25
|
-
|
26
|
-
|
29
|
+
return true if @logged_in
|
30
|
+
|
31
|
+
page = agent.get('https://sellercentral.amazon.com/gp/homepage.html')
|
32
|
+
form = page.form_with(:name => 'signinWidget')
|
27
33
|
|
28
34
|
begin
|
29
|
-
form['
|
35
|
+
form['username'] = login_email
|
30
36
|
form['password'] = login_password
|
31
|
-
form.submit
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
p = form.submit
|
38
|
+
if p =~ /better protect/ # capcha!
|
39
|
+
raise CapchaPresentError.new("Holy CAPCHA Batman!")
|
40
|
+
end
|
41
|
+
@logged_in = !!( p.body =~ /Logout/ && p.body =~ /Manage Inventory/ )
|
42
|
+
|
43
|
+
rescue StandardError => e
|
44
|
+
File.open("/tmp/seller_central_#{Time.now.to_i}.html","wb") do |f|
|
35
45
|
f.write page.body
|
36
46
|
end
|
37
|
-
raise
|
47
|
+
raise e
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
@@ -47,11 +57,13 @@ module AmazonSellerCentral
|
|
47
57
|
|
48
58
|
def reset!
|
49
59
|
@agent = nil
|
60
|
+
@logged_in = false
|
50
61
|
#@last_page = nil
|
51
62
|
end
|
52
63
|
|
53
64
|
class LinkNotFoundError < StandardError; end
|
54
65
|
class AgentResetError < StandardError; end
|
66
|
+
class CapchaPresentError < StandardError; end
|
55
67
|
|
56
68
|
end
|
57
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_seller_central
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &15891100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15891100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &15888840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.3.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15888840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &15874060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15874060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &15869900 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *15869900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &15848500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *15848500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &15838920 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *15838920
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard
|
82
|
-
requirement: &
|
82
|
+
requirement: &15836740 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *15836740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard-rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &15823760 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *15823760
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rb-inotify
|
104
|
-
requirement: &
|
104
|
+
requirement: &15820200 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.8.5
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *15820200
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: libnotify
|
115
|
-
requirement: &
|
115
|
+
requirement: &15804000 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *15804000
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: ffi
|
126
|
-
requirement: &
|
126
|
+
requirement: &15801000 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *15801000
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: faker
|
137
|
-
requirement: &
|
137
|
+
requirement: &15784820 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *15784820
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: fakeweb
|
148
|
-
requirement: &
|
148
|
+
requirement: &15778320 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *15778320
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: ruby-debug19
|
159
|
-
requirement: &
|
159
|
+
requirement: &15775600 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *15775600
|
168
168
|
description: This gem is intended to wrap Amazon's SellerCentral pages with a Ruby
|
169
169
|
API. Currently this gem supports accessing buyer feedback only.
|
170
170
|
email: dev@optoro.com
|
@@ -247,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
segments:
|
249
249
|
- 0
|
250
|
-
hash:
|
250
|
+
hash: -2618572989315331701
|
251
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
252
|
none: false
|
253
253
|
requirements:
|