google_search_results 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad56c82937a90531cdebbddfa443885bb58848e8b165387263a72968e656a8aa
4
- data.tar.gz: be506a5558ad74878c37faac39eb2477b377547e63cba06e631e7c4f83145806
3
+ metadata.gz: c9850029f90956175395320f506e034bf6373397954c31452cef7e4fbe56d46d
4
+ data.tar.gz: '082c1dc59ab2526df21009b2bf127378c76039c828a7bee459b8efd1f8e9c58b'
5
5
  SHA512:
6
- metadata.gz: b39e137c299bb240a5194af347917170b85754394ef793f57c2843d9d0dced7558aef2a37ad907e431eeebbd558fd0f93ab40212d5a214a75b66ff5b50479e47
7
- data.tar.gz: cab293e5a8883b81403fe802d59a4dfcf5078e822dddd62503e5b9ea46335b186e0bb50ea1cdc4838a80bb1db434a6feb6acae6831b27c44e0cfffd83885c495
6
+ metadata.gz: 810293f9210d09d120d50123cf593d42c958204beb7154922f839ca217dd8d093518401fd59a1842f06e6e67b5e18b9cc16984b2df6bdd0d43a4f98508304cfa
7
+ data.tar.gz: e2aedc34c37f8b4779651e475c3b21011680d783686557bb562bdb546b98bf074f31256933aad066e21ce78988696bade30630e4690290e494e0d3dc291d2634
@@ -5,3 +5,7 @@ require_relative 'search/ebay_search.rb'
5
5
  require_relative 'search/google_search.rb'
6
6
  require_relative 'search/yahoo_search.rb'
7
7
  require_relative 'search/yandex_search.rb'
8
+ require_relative 'search/youtube_search.rb'
9
+ require_relative 'search/walmart_search.rb'
10
+ require_relative 'search/duckduckgo_search.rb'
11
+ require_relative 'search/homedepot_search.rb'
@@ -22,12 +22,12 @@ require_relative 'serp_api_search'
22
22
  class BaiduSearch < SerpApiSearch
23
23
 
24
24
  def initialize(params = {})
25
- super(params, BING_ENGINE)
25
+ super(params, BAIDU_ENGINE)
26
26
  check_params([:q, :engine])
27
27
  end
28
28
 
29
29
  def get_location
30
- raise 'location is not supported by Baidu'
30
+ raise SerpApiException.new('location is not supported by Baidu')
31
31
  end
32
32
 
33
33
  end
@@ -0,0 +1,29 @@
1
+ require_relative 'serp_api_search'
2
+
3
+ # Duckduckgo Search Result for Ruby powered by SerpApi
4
+ #
5
+ # Search API Usage
6
+ #
7
+ # ```ruby
8
+ # parameter = {
9
+ # search_query: "query",
10
+ # api_key: "Serp API Key"
11
+ # }
12
+ #
13
+ # search = DuckduckgoSearch.new(parameter)
14
+ #
15
+ # html_results = search.get_html
16
+ # hash_results = search.get_hash
17
+ # json_results = search.get_json
18
+ #
19
+ # ```
20
+ # doc: https://serpapi.com/Duckduckgo-search-api
21
+
22
+ class DuckduckgoSearch < SerpApiSearch
23
+
24
+ def initialize(params = {})
25
+ super(params, DUCKDUCKGO_ENGINE)
26
+ check_params([:q, :engine])
27
+ end
28
+
29
+ end
@@ -29,7 +29,7 @@ class EbaySearch < SerpApiSearch
29
29
  end
30
30
 
31
31
  def get_location
32
- raise 'location is not supported by ' + EBAY_ENGINE
32
+ raise SerpApiException.new('location is not supported by ' + EBAY_ENGINE)
33
33
  end
34
34
 
35
35
  end
@@ -0,0 +1,33 @@
1
+ require_relative 'serp_api_search'
2
+
3
+ # Homedepot Search Result for Ruby powered by SerpApi
4
+ #
5
+ # Search API Usage
6
+ #
7
+ # ```ruby
8
+ # parameter = {
9
+ # search_query: "query",
10
+ # api_key: "Serp API Key"
11
+ # }
12
+ #
13
+ # search = HomedepotSearch.new(parameter)
14
+ #
15
+ # html_results = search.get_html
16
+ # hash_results = search.get_hash
17
+ # json_results = search.get_json
18
+ #
19
+ # ```
20
+ # doc: https://serpapi.com/Homedepot-search-api
21
+
22
+ class HomedepotSearch < SerpApiSearch
23
+
24
+ def initialize(params = {})
25
+ super(params, HOMEDEPOT_ENGINE)
26
+ check_params([:q, :engine])
27
+ end
28
+
29
+ def get_location
30
+ raise SerpApiException.new('location is not supported by Homedepot')
31
+ end
32
+
33
+ end
@@ -7,13 +7,16 @@ BING_ENGINE = 'bing'
7
7
  YAHOO_ENGINE = 'yahoo'
8
8
  YANDEX_ENGINE = 'yandex'
9
9
  EBAY_ENGINE = 'ebay'
10
-
10
+ YOUTUBE_ENGINE = 'youtube'
11
+ DUCKDUCKGO_ENGINE = 'duckduckgo'
12
+ WALMART_ENGINE = 'walmart'
13
+ HOMEDEPOT_ENGINE = 'home_depot'
11
14
 
12
15
  # Generic HTTP client for serpapi.com
13
16
  #
14
17
  class SerpApiSearch
15
18
 
16
- VERSION = "2.0.1"
19
+ VERSION = "2.1.0"
17
20
  BACKEND = "serpapi.com"
18
21
 
19
22
  attr_accessor :params
@@ -34,7 +37,7 @@ class SerpApiSearch
34
37
  def initialize(params, engine = nil)
35
38
  @params = params
36
39
  @params[:engine] ||= engine
37
- raise 'engine must be defined in params or a second argument' if @params[:engine].nil?
40
+ raise SerpApiException.new('engine must be defined in params or a second argument') if @params[:engine].nil?
38
41
  end
39
42
 
40
43
  # get_json
@@ -78,7 +81,7 @@ class SerpApiSearch
78
81
 
79
82
  # Retrieve search result from the Search Archive API
80
83
  def get_search_archive(search_id, format = 'json')
81
- raise 'format must be json or html' if format !~ /^(html|json)$/
84
+ raise SerpApiException.new('format must be json or html') if format !~ /^(html|json)$/
82
85
  as_json(get_results("/searches/#{search_id}.#{format}"))
83
86
  end
84
87
 
@@ -149,7 +152,7 @@ class SerpApiSearch
149
152
  def check_params(keys = [])
150
153
  return if @params.keys == [:engine]
151
154
 
152
- raise 'keys must be a list of String or Symbol' unless keys.class == Array
155
+ raise SerpApiException.new('keys must be a list of String or Symbol') unless keys.class == Array
153
156
  missing = []
154
157
  keys.each do |key|
155
158
  case key.class.to_s
@@ -166,13 +169,19 @@ class SerpApiSearch
166
169
  end
167
170
  end
168
171
  else
169
- raise 'keys must contains Symbol or String'
172
+ raise SerpApiException.new('keys must contains Symbol or String')
170
173
  end
171
174
  end
172
175
  if !missing.empty?
173
- raise "missing required keys in params.\n #{missing.join(',')}"
176
+ raise SerpApiException.new("missing required keys in params.\n #{missing.join(',')}")
174
177
  end
175
178
  end
176
179
 
177
180
  end
178
181
 
182
+ # Standard SerpApiException for anything related to the client
183
+ class SerpApiException < StandardError
184
+ def initialize(message)
185
+ super(message)
186
+ end
187
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'serp_api_search'
2
+
3
+ # Walmart Search Result for Ruby powered by SerpApi
4
+ #
5
+ # Search API Usage
6
+ #
7
+ # ```ruby
8
+ # parameter = {
9
+ # query: "search keywords",
10
+ # api_key: "Serp API Key"
11
+ # }
12
+ #
13
+ # search = WalmartSearch.new(parameter)
14
+ #
15
+ # html_results = search.get_html
16
+ # hash_results = search.get_hash
17
+ # json_results = search.get_json
18
+ #
19
+ # ```
20
+ # doc: https://serpapi.com/youtube-search-api
21
+
22
+ class WalmartSearch < SerpApiSearch
23
+
24
+ def initialize(params = {})
25
+ super(params, WALMART_ENGINE)
26
+ check_params([:query, :engine])
27
+ end
28
+
29
+ def get_location
30
+ raise SerpApiException.new('location is not supported by Walmart')
31
+ end
32
+
33
+ end
@@ -29,7 +29,7 @@ class YahooSearch < SerpApiSearch
29
29
  end
30
30
 
31
31
  def get_location
32
- raise 'location is not supported by ' + YAHOO_ENGINE
32
+ raise SerpApiException.new('location is not supported by ' + YAHOO_ENGINE)
33
33
  end
34
34
 
35
35
  end
@@ -29,7 +29,7 @@ class YandexSearch < SerpApiSearch
29
29
  end
30
30
 
31
31
  def get_location
32
- raise 'location is not supported by ' + YAHOO_ENGINE
32
+ raise SerpApiException.new('location is not supported by ' + YAHOO_ENGINE)
33
33
  end
34
34
 
35
35
  end
@@ -0,0 +1,29 @@
1
+ require_relative 'serp_api_search'
2
+
3
+ # Youtube Search Result for Ruby powered by SerpApi
4
+ #
5
+ # Search API Usage
6
+ #
7
+ # ```ruby
8
+ # parameter = {
9
+ # search_query: "query",
10
+ # api_key: "Serp API Key"
11
+ # }
12
+ #
13
+ # search = YoutubeSearch.new(parameter)
14
+ #
15
+ # html_results = search.get_html
16
+ # hash_results = search.get_hash
17
+ # json_results = search.get_json
18
+ #
19
+ # ```
20
+ # doc: https://serpapi.com/youtube-search-api
21
+
22
+ class YoutubeSearch < SerpApiSearch
23
+
24
+ def initialize(params = {})
25
+ super(params, YOUTUBE_ENGINE)
26
+ check_params([:search_query, :engine])
27
+ end
28
+
29
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_search_results
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hartator
8
8
  - jvmvik
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-22 00:00:00.000000000 Z
12
+ date: 2021-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -77,17 +77,21 @@ files:
77
77
  - lib/google_search_results.rb
78
78
  - lib/search/baidu_search.rb
79
79
  - lib/search/bing_search.rb
80
+ - lib/search/duckduckgo_search.rb
80
81
  - lib/search/ebay_search.rb
81
82
  - lib/search/google_search.rb
83
+ - lib/search/homedepot_search.rb
82
84
  - lib/search/serp_api_search.rb
85
+ - lib/search/walmart_search.rb
83
86
  - lib/search/yahoo_search.rb
84
87
  - lib/search/yandex_search.rb
88
+ - lib/search/youtube_search.rb
85
89
  homepage: https://github.com/serpapi/google-search-results-ruby
86
90
  licenses:
87
91
  - MIT
88
92
  metadata:
89
93
  yard.run: yri
90
- post_install_message:
94
+ post_install_message:
91
95
  rdoc_options: []
92
96
  require_paths:
93
97
  - lib
@@ -102,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
106
  - !ruby/object:Gem::Version
103
107
  version: '0'
104
108
  requirements: []
105
- rubygems_version: 3.1.2
106
- signing_key:
109
+ rubygems_version: 3.0.3
110
+ signing_key:
107
111
  specification_version: 4
108
112
  summary: Get Google, Bing, Baidu, Ebay, Yahoo, Yandex Search Results via SerpApi.com
109
113
  test_files: []