Sha256: b9182b64349a7a78bd0afd7f69fdcd188237b782a64b1c2f9b91209820ee95cf

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

## get Google search history -- IKeJI
##
## for example you can get your search keyword 'harahetta'
##
## -module: Feed::google_search_history
##  config:
##    user: hoge
##    pass: fuga
##

require 'net/https'
require 'rss/1.0'
require 'rss/2.0'
require 'rss/maker'

def google_search_history(config,data)
  Net::HTTP.version_1_2
  req = Net::HTTP::Get.new('/searchhistory/?output=rss')
  req["Accept-Language"] = "ja"
  req["Accept-Charset"] = "utf-8"
  req.basic_auth config['user'],config['pass']
  ht = Net::HTTP.new("www.google.com",443)
  ht.use_ssl = true
  ht.start do |http|
    while(true)
      response = http.request(req)
      if(response.kind_of? Net::HTTPRedirection )
        req = Net::HTTP::Get.new(response['location'])
        req["Accept-Language"] = "ja"
        req["Accept-Charset"] = "utf-8"
        req.basic_auth config['user'],config['pass']
      else
        break
      end
    end
    rss = nil
    begin
      rss = RSS::Parser.parse(response.body)
    rescue RSS::InvalidRSSError
      rss = RSS::Parser.parse(response.body, false)
    end
    return rss.items rescue []
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yapra-0.2.2 legacy_plugins/Feed/google_search_history.rb
yapra-0.2.0 legacy_plugins/Feed/google_search_history.rb
yapra-0.1.3 legacy_plugins/Feed/google_search_history.rb
yapra-0.1.1 legacy_plugins/Feed/google_search_history.rb
yapra-0.1.0 legacy_plugins/Feed/google_search_history.rb
yapra-0.1.2 legacy_plugins/Feed/google_search_history.rb