简体   繁体   中英

Google search gem results

i am using awesome google-search gem for search some info in google.

This is my ruby (model Items belongs_to Product) :

require 'rubygems'
require "google-search"

  query = "Some query for google"
  Google::Search::Web.new do |search|
    search.query = query
    puts search.first.uri
  end

But often i got results not same like in my browser. I guess its all about my account, because google range searched data by my search history and google-search gem has no this history.

Who know how i can solve this issue that got more relevant result from google ?

As this gem is now deprecated, we built our own gem . It's quite simple to use:

query_params = {
  q: "query",
  google_domain: "Google Domain", 
  location: "Location Requested", 
  device: device,
  hl: "Google UI Language",
  gl: "Google Country",
  num: "Number of Results",
}
query = GoogleSearchResults.new query_params
hash_results = query.get_hash
html_results = query.get_html
json_results = query.get_json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM