amazon-search 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/amazon-search.rb +16 -25
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 158b6c001ca75de6db5932613400e66da3bcee12
4
- data.tar.gz: b704070c66c130cc3ec7dbc36e9b10a2e847d18b
3
+ metadata.gz: 1d9464f71fde7ee69a0859f396294c5314751886
4
+ data.tar.gz: c5bc777baa5e07f64abea86e4cf450384e1e2c30
5
5
  SHA512:
6
- metadata.gz: 03251d475f4544cf5aa91bd444dfddb16a225b1863e4afdabc32aa44d6e591814f2e886bd7599c0b88903e8445ab7810fbaee26eae266d9e1c09f67af541f781
7
- data.tar.gz: c14203ba29639639933c6798d0edc4b02fce4e441b87e621ab4ccc7bff00e7fcebd64190960a812120176d9d2d523055d722e40a2b2a393202b9240a12186e4c
6
+ metadata.gz: 1193508bd1dca50f242cf88da56cc9aeb1e159917a800f91dd403ff92a421588b7ac67bf3f35c2d12fb3aca0ef178027c4719067aa1c24d9e5fd549f1380687d
7
+ data.tar.gz: 407a8b0fecee06bbe4b71bbf39cd6a484e75c266c4e5595bf738733439c0aef2a6086769e79cea10fb6612bf782666dbcfd90a3873a2a8daaa26bc517deb1f53
data/lib/amazon-search.rb CHANGED
@@ -4,24 +4,27 @@ require 'mechanize'
4
4
  require 'thor'
5
5
 
6
6
  def search(keywords)
7
- ###########################################
8
- # Select Amazon search form and submit
9
- # the search criteria
10
- ###########################################
11
7
 
12
- agent = Mechanize.new
13
- main_page = agent.get("http://amazon.com")
14
- search_form = main_page.form_with :name => "site-search"
15
8
 
16
- if keywords.nil? false # did user enter in search keywords?
9
+ if keywords.nil? # did user forget to enter in search keywords?
10
+ STDOUT.puts """
11
+ Please provide search keywords
12
+
13
+ Example Usage:
14
+ search watches
15
+ search books
16
+ search games
17
+
18
+ """
19
+ else
20
+
21
+ agent = Mechanize.new
22
+ main_page = agent.get("http://amazon.com")
23
+ search_form = main_page.form_with :name => "site-search" # find the search form in Amazon
24
+
17
25
  search_form.field_with(:name => "field-keywords").value = keywords # sets value of search box
18
26
  search_results = agent.submit search_form # submits form
19
27
 
20
- ###########################################
21
- # Cycle through all result pages
22
- # and list product links
23
- ###########################################
24
-
25
28
  next_page = agent.get(search_results.uri) # initial search results are the first page
26
29
 
27
30
  # last page is disabled nav button in search results
@@ -100,17 +103,5 @@ if keywords.nil? false # did user enter in search keywords?
100
103
 
101
104
  puts "\n\n(end of search results)"
102
105
 
103
- else # user didn't enter search keywords
104
-
105
- STDOUT.puts <<-EOF
106
- Please provide search keywords
107
-
108
- Example Usage:
109
- search watches
110
- search books
111
- search games
112
-
113
- EOF
114
-
115
106
  end # ends ARGV if statement
116
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mason