amazon-search 1.0.0 → 1.1.0

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 +8 -7
  3. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 024a711312063a079ab5ee3baeae8a56d0537d60
4
- data.tar.gz: b9ad814071d0da1bae9f452ea002ee38384946b9
3
+ metadata.gz: 158b6c001ca75de6db5932613400e66da3bcee12
4
+ data.tar.gz: b704070c66c130cc3ec7dbc36e9b10a2e847d18b
5
5
  SHA512:
6
- metadata.gz: eab2f63c98a7aaaaa8133bfba0d4e54096afda88cca291d9e97aa6e8881a91511184fa1420e5330b02d748609e8c52164425635a5d02e8c9f4c8d8bfc6889e92
7
- data.tar.gz: 3d4ada9d06805ef319997001236bcb1b9702f7811d7eb1a88e6b4a39115fbd64bb4afa7299246d85353ee1b8af3f961f34dbeef2cafa800719fd2eab1fd035bb
6
+ metadata.gz: 03251d475f4544cf5aa91bd444dfddb16a225b1863e4afdabc32aa44d6e591814f2e886bd7599c0b88903e8445ab7810fbaee26eae266d9e1c09f67af541f781
7
+ data.tar.gz: c14203ba29639639933c6798d0edc4b02fce4e441b87e621ab4ccc7bff00e7fcebd64190960a812120176d9d2d523055d722e40a2b2a393202b9240a12186e4c
data/lib/amazon-search.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'mechanize'
4
+ require 'thor'
4
5
 
6
+ def search(keywords)
5
7
  ###########################################
6
8
  # Select Amazon search form and submit
7
9
  # the search criteria
@@ -11,9 +13,7 @@ agent = Mechanize.new
11
13
  main_page = agent.get("http://amazon.com")
12
14
  search_form = main_page.form_with :name => "site-search"
13
15
 
14
- keywords = ARGV[0] # asks for search terms
15
-
16
- if ARGV[0] # did user enter in search keywords?
16
+ if keywords.nil? false # did user enter in search keywords?
17
17
  search_form.field_with(:name => "field-keywords").value = keywords # sets value of search box
18
18
  search_results = agent.submit search_form # submits form
19
19
 
@@ -106,10 +106,11 @@ STDOUT.puts <<-EOF
106
106
  Please provide search keywords
107
107
 
108
108
  Example Usage:
109
- amazon-search watches
110
- amazon-search books
111
- amazon-search games
109
+ search watches
110
+ search books
111
+ search games
112
112
 
113
113
  EOF
114
114
 
115
- end # ends ARGV if statement
115
+ end # ends ARGV if statement
116
+ 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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mason
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
27
41
  description: Simple screenscraper to search Amazon and return product titles, urls,
28
42
  image href, etc.
29
43
  email: mace2345@gmail.com