google-search-results-ruby
google-search-results-ruby copied to clipboard
Gem forces the use of `q` parameter for engines that is not used
We have several engines that work without a q parameter.
For example, Yande uses text:

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.
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>'
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.
I'm still facing the same issue with yahoo
This is resolved by https://github.com/serpapi/serpapi-ruby The gem should be published soon.
+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.