@@ -4,13 +4,17 @@ def snippet(format, path, demo = false)
44 if demo
55 buf = lines[1..-1].join
66 else
7+ # select test from line start to stop
8+ start = 9
79 stop = lines.find_index { |line| line =~ /pp results/}
8- slice = File.new(path).readlines[2..stop+1]
9- slice.reject! { |l| l =~ /expect\(/ }
10- buf = slice.map { |l| l.gsub(/(^\s\s\s\s)/, '')}.join
10+ slice = File.new(path).readlines[start..stop+1]
11+ slice.reject! { |l| l =~ /expect\(|^\s*describe|^\s+it|^\s*end\s*$/ }
12+ slice.map! { |l| l.gsub(/(^\s\s\s\s)/, '')}
13+ buf = slice.join
1114 buf.gsub!('# pp ', 'pp ')
15+ buf.gsub!('api_key)', "ENV['API_KEY'])")
1216 end
13- %Q(```#{format}\nrequire 'serpapi'\n#{buf}\n ```\n\n * source code: [#{path}](https://github.com/serpapi/serpapi-ruby/blob/master/#{path}))
17+ %Q(```#{format}\nrequire 'serpapi'\n#{buf}```\n\n * source code: [#{path}](https://github.com/serpapi/serpapi-ruby/blob/master/#{path}))
1418end
1519-%>
1620 <div align ="center ">
@@ -27,7 +31,8 @@ SerpApi supports Google, Google Maps, Google Shopping, Baidu, Yandex, Yahoo, eBa
2731
2832## Installation
2933
30- Ruby 1.9.3 (or more recent), JRuby 9.1.17 (or more recent), or TruffleRuby 19.3.0 (or more recent) is required.
34+ Ruby 3+ must be installed for best performance the latest version 3.4 is recommended.
35+ For older version of Ruby 1.9 and 2.x or JRuby, our older library is still functional.
3136
3237### Bundler
3338```ruby
@@ -75,7 +80,7 @@ params = {
7580 # then adds search engine specific options.
7681 # for example: google specific parameters: https://serpapi.com/search-api
7782 google_domain: "Google Domain",
78- location: "Location Requested", # example: Portland,Oregon,United States [see : Location API](#Location-API)
83+ location: "Location Requested", # example: Portland,Oregon,United States [ * doc : Location API](#Location-API)
7984 device: "desktop|mobile|tablet",
8085 hl: "Google UI Language",
8186 gl: "Google Country",
@@ -191,48 +196,10 @@ pp data
191196
192197## Basic example per search engine
193198
194- ### Search bing
195- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_bing_spec.rb' ) %>
196- * doc: [https://serpapi.com/bing-search-api](https://serpapi.com/bing-search-api)
199+ Here is how to calls the APIs.
197200
198- ### Search baidu
199- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_baidu_spec.rb' ) %>
200- * doc: [https://serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api)
201-
202- ### Search yahoo
203- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_yahoo_spec.rb' ) %>
204- * doc: [https://serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api)
205-
206- ### Search youtube
207- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_youtube_spec.rb' ) %>
208- * doc: [https://serpapi.com/youtube-search-api](https://serpapi.com/youtube-search-api)
209-
210- ### Search walmart
211- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_walmart_spec.rb' ) %>
212- * doc: [https://serpapi.com/walmart-search-api](https://serpapi.com/walmart-search-api)
213-
214- ### Search ebay
215- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_ebay_spec.rb' ) %>
216- * doc: [https://serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)
217-
218- ### Search naver
219- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_naver_spec.rb' ) %>
220- * doc: [https://serpapi.com/naver-search-api](https://serpapi.com/naver-search-api)
221-
222- ### Search home depot
223- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_home_depot_spec.rb' ) %>
224- * doc: [https://serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-search-api)
225-
226- ### Search apple app store
227- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_apple_app_store_spec.rb' ) %>
228- * doc: [https://serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)
229-
230- ### Search duckduckgo
231- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_duckduckgo_spec.rb' ) %>
232- * doc: [https://serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-search-api)
233-
234- ### Search google search
235- <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_search_spec.rb' ) %>
201+ ### Search google
202+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_spec.rb' ) %>
236203 * doc: [https://serpapi.com/search-api](https://serpapi.com/search-api)
237204
238205### Search google scholar
@@ -275,6 +242,82 @@ pp data
275242<%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_images_spec.rb' ) %>
276243 * doc: [https://serpapi.com/images-results](https://serpapi.com/images-results)
277244
245+ ### Search google lens
246+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_lens_spec.rb' ) %>
247+ * doc: [https://serpapi.com/google-lens-api](https://serpapi.com/google-lens-api)
248+
249+ ### Search google images light
250+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_images_light_spec.rb' ) %>
251+ * doc: [https://serpapi.com/google-images-light-api](https://serpapi.com/google-images-light-api)
252+
253+ ### Search google hotels
254+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_hotels_spec.rb' ) %>
255+ * doc: [https://serpapi.com/google-hotels-api](https://serpapi.com/google-hotels-api)
256+
257+ ### Search google flights
258+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_flights_spec.rb' ) %>
259+ * doc: [https://serpapi.com/google-flights-api](https://serpapi.com/google-flights-api)
260+
261+ ### Search google finance
262+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_finance_spec.rb' ) %>
263+ * doc: [https://serpapi.com/google-finance-api](https://serpapi.com/google-finance-api)
264+
265+ ### Search google ai overview
266+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_ai_overview_spec.rb' ) %>
267+ * doc: [https://serpapi.com/google-ai-overview-api](https://serpapi.com/google-ai-overview-api)
268+
269+ ### Search google news
270+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_news_spec.rb' ) %>
271+ * doc: [https://serpapi.com/google-news-api](https://serpapi.com/google-news-api)
272+
273+ ### Search google patents
274+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_patents_spec.rb' ) %>
275+ * doc: [https://serpapi.com/google-patents-api](https://serpapi.com/google-patents-api)
276+
277+ ### Search google trends
278+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_trends_spec.rb' ) %>
279+ * doc: [https://serpapi.com/google-trends-api](https://serpapi.com/google-trends-api)
280+
281+ ### Search google shopping
282+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_google_shopping_spec.rb' ) %>
283+ * doc: [https://serpapi.com/google-shopping-api](https://serpapi.com/google-shopping-api)
284+
285+ ### Search baidu
286+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_baidu_spec.rb' ) %>
287+ * doc: [https://serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api)
288+
289+ ### Search yahoo
290+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_yahoo_spec.rb' ) %>
291+ * doc: [https://serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api)
292+
293+ ### Search youtube
294+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_youtube_spec.rb' ) %>
295+ * doc: [https://serpapi.com/youtube-search-api](https://serpapi.com/youtube-search-api)
296+
297+ ### Search walmart
298+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_walmart_spec.rb' ) %>
299+ * doc: [https://serpapi.com/walmart-search-api](https://serpapi.com/walmart-search-api)
300+
301+ ### Search ebay
302+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_ebay_spec.rb' ) %>
303+ * doc: [https://serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)
304+
305+ ### Search naver
306+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_naver_spec.rb' ) %>
307+ * doc: [https://serpapi.com/naver-search-api](https://serpapi.com/naver-search-api)
308+
309+ ### Search home depot
310+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_home_depot_spec.rb' ) %>
311+ * doc: [https://serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-search-api)
312+
313+ ### Search apple app store
314+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_apple_app_store_spec.rb' ) %>
315+ * doc: [https://serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)
316+
317+ ### Search duckduckgo
318+ <%= snippet ( 'ruby' , 'spec/serpapi/client/example/example_search_duckduckgo_spec.rb' ) %>
319+ * doc: [https://serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-search-api)
320+
278321## Migration quick guide
279322
280323if you were already using (google-search-results-ruby gem)[https://github.com/serpapi/google-search-results-ruby], here are the changes.
@@ -358,7 +401,7 @@ Each search takes a few seconds before completion by SerpApi service and the sea
358401Ruby versions validated by Github Actions:
359402 - 3.1
360403 - 2.6
361- see : [Github Actions.](https://github.com/serpapi/serpapi-ruby/actions/workflows/ci.yml)
404+ * doc : [Github Actions.](https://github.com/serpapi/serpapi-ruby/actions/workflows/ci.yml)
362405
363406## Change logs
364407 * [2023-02-20] 1.0.0 Full API support
0 commit comments