google-search-results-ruby icon indicating copy to clipboard operation
google-search-results-ruby copied to clipboard

Gem forces the use of `q` parameter for engines that is not used

Open hartator opened this issue 3 years ago • 5 comments

We have several engines that work without a q parameter.

For example, Yande uses text:

image

And you can't submit your search to the API.

Hash with all engines that don't use q parameter:

{
  ebay: '_nkw',
  google_maps_reviews: 'data_id',
  google_product: 'product_id',
  google_scholar_author: 'author_id',
  google_scholar_profiles: 'mauthors',
  home_depot_product: 'product_id',
  walmart: 'query',
  walmart_product: 'product_id',
  yahoo: 'p',
  yandex: 'text',
  youtube: 'search_query',
  naver: 'query',
  apple_app_store: 'term',
  apple_reviews: 'product_id',
  yahoo_shopping: 'p',
  google_play_product: 'product_id',
}

We can explicitly check on this but I think it will easier to just drop the requirement of a q parameter for all engines.

hartator avatar Jan 22 '22 21:01 hartator

Happened again

Request: {
  :engine=>"yahoo", 
  :p=>"serpapi", 
  :api_key=>"<censored>"
}

/home/<censored>/.gem/ruby/3.0.0/gems/google_search_results-2.2.0/lib/search/serp_api_search.rb:178:in `check_params': missing required keys in params:  (SerpApiException)
 - q
        from /home/<censored>/.gem/ruby/3.0.0/gems/google_search_results-2.2.0/lib/search/google_search.rb:36:in `initialize'
        from se_everywhere.rb:41:in `new'
        from se_everywhere.rb:41:in `block in <main>'
        from se_everywhere.rb:32:in `each'
        from se_everywhere.rb:32:in `<main>'

DEADF00D avatar Mar 17 '22 18:03 DEADF00D

Actually, The library the right, and playground is false. Yahoo requirements are already defined under the YahooSearch class:

class YahooSearch < SerpApiSearch
  def initialize(params = {})
    super(params, YAHOO_ENGINE)
    check_params([:p, :engine])
  end
  ...
end

By replacing the GoogleSearch class by YahooSearch. It's now working.

We should fix code generation from API Playground to change class depending of the engine used.

DEADF00D avatar Mar 17 '22 19:03 DEADF00D

I'm still facing the same issue with yahoo

Screen Shot 2023-03-01 at 2 46 14 PM

paigebutler avatar Mar 01 '23 20:03 paigebutler

This is resolved by https://github.com/serpapi/serpapi-ruby The gem should be published soon.

jvmvik avatar Mar 30 '23 01:03 jvmvik

+1 Seeing this issue when using the google_search_results ruby gem. Is there a pending fix for this? Also, I noticed the gem for the https://github.com/serpapi/serpapi-ruby library doesn't exist and that the library is in draft stage at the moment. I want to suggest adding a note about it in the github documentation (readme, etc) can be helpful.

sonika-serpapi avatar Jul 12 '24 23:07 sonika-serpapi