Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hartator opened this issue Jan 22, 2022 · 5 comments
Open

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

hartator opened this issue Jan 22, 2022 · 5 comments

Comments

@hartator
Copy link
Collaborator

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.

@DEADF00D
Copy link

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
Copy link

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.

@paigebutler
Copy link

I'm still facing the same issue with yahoo

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

@jvmvik
Copy link
Contributor

jvmvik commented Mar 30, 2023

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

@sonika-serpapi
Copy link

+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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants