Class: StoreApi::GooglePlay::Apps::Search

Inherits:
Object
  • Object
show all
Includes:
Card, Request
Defined in:
lib/store_api/google_play/apps/search.rb

Overview

google play search class

Constant Summary

Constants included from Request

Request::TIME_OUT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Card

#parse

Methods included from Request

#get, #post, #request

Constructor Details

#initialize(search_word, lang = nil, limit = nil, proxy = nil, header = nil) ⇒ Search

Returns a new instance of Search.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/store_api/google_play/apps/search.rb', line 13

def initialize(search_word,lang=nil,limit=nil,proxy=nil,header=nil)
  params = {'q' => search_word,'c' => 'apps' }
  if !lang.nil?
    params['hl'] = lang
  end
  @@path = URI.escape("/store/search")
  @search_list = []
  num = 60
  # TODO search limit
  (0..2).each do |start|
    begin
      params['start'] = start*60
      params['num'] = num
      html = post(StoreApi::GooglePlay::HOST,@@path,params,StoreApi::GooglePlay::HTTPS,proxy,header)
      doc = Nokogiri::HTML(html,nil,'utf-8')
      @search_list.concat(parse(doc))
    rescue => e
      puts e.backtrace
      puts e.message
      break
    end
  end
end

Instance Attribute Details

#search_listObject

Returns the value of attribute search_list.



11
12
13
# File 'lib/store_api/google_play/apps/search.rb', line 11

def search_list
  @search_list
end

Instance Method Details

#mainObject



37
38
# File 'lib/store_api/google_play/apps/search.rb', line 37

def main
end