class GooglePlaySearch::Search
Constants
- DEFAULT_SEARCH_CONDITION
- GOOGLE_PLAY_BASE_SEARCH_URL
Attributes
current_page[RW]
keyword[RW]
Public Class Methods
new(search_condition = DEFAULT_SEARCH_CONDITION)
click to toggle source
# File lib/google_play_search/search.rb, line 20 def initialize(search_condition = DEFAULT_SEARCH_CONDITION) @search_condition = DEFAULT_SEARCH_CONDITION.merge(search_condition) @next_page_token = nil @current_page = 1 end
Public Instance Methods
next_page()
click to toggle source
# File lib/google_play_search/search.rb, line 32 def next_page() @current_page += 1 search @keyword end
search(keyword, options = {})
click to toggle source
# File lib/google_play_search/search.rb, line 26 def search(keyword, options = {}) @keyword = keyword page = HTTPClient.new.get(GOOGLE_PLAY_BASE_SEARCH_URL, query_params).body AppParser.new(page).parse end
Private Instance Methods
get_next_page_token(response_body)
click to toggle source
# File lib/google_play_search/search.rb, line 55 def get_next_page_token(response_body) if response_body.match(/(GAEi+.+:S:.{11})\\42/) @next_page_token = $~[1][-22..-1] end end
query_params()
click to toggle source
# File lib/google_play_search/search.rb, line 39 def query_params params = { "q" => @keyword, "c" => @search_condition[:category], "hl" => @search_condition[:language], "price" => @search_condition[:price], "rating" => @search_condition[:rating], "start" => 0, "num" => 0, } if @next_page_token params["pagTok"] = @next_page_token end params end