google_play_search 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e03b69dab8d61ca7e4fbe09a365b63925669035a
4
- data.tar.gz: c5a4de813eca47ef36aa460a9f9d875814c9ef92
3
+ metadata.gz: 8b6c6d9904e4e95f237945ab0945975624d80a2c
4
+ data.tar.gz: 310d5be7e53b3e4fbd7ba779f41bcb80e3c54274
5
5
  SHA512:
6
- metadata.gz: 36ca80a8d2cd2501c58f9c7e43fe5984146bf1ac65abc3ce8db1e53d3feac3a97ad8e73543097c9ca1926e0a746e239e1cf56191d54be7cd254997cf2b3c9d7a
7
- data.tar.gz: 49083815fb1bfed7567e602c4bf7be5058582102959d4f2c1bb2685ab628ba65a38c4d6266bf0f28d32d55be5ffd60ee59d68d8fb26677885c2be65074b56b4d
6
+ metadata.gz: afdcba6273839fd59aed5574c475223236d613f1f2427c54008676caf8778bdb8c7f669c31ebdc6df3718cb343365bcc625bd514ef85408f3ef4f134ca746e90
7
+ data.tar.gz: 4955076d469b0da3cbd39ed613914e13586a88ad06aad72d27d7dad91cba66591d0cd1eecb4b04601125fb74b4644e1e21f01f873656f6d6683a59507e32fdd3
@@ -14,26 +14,27 @@ module GooglePlaySearch
14
14
 
15
15
  DEFAULT_SEARCH_CONDITION = {:language => "en",
16
16
  :category => "apps",
17
- :per_page_num => 24,
17
+ #:per_page_num => 20,
18
18
  :price => "0",
19
- :safe_search => "0",
20
- :sort_by => "1"}
19
+ #:safe_search => "0",
20
+ :rating => "0"}
21
21
 
22
22
  def initialize(search_condition = DEFAULT_SEARCH_CONDITION)
23
23
  @search_condition = DEFAULT_SEARCH_CONDITION.merge(search_condition)
24
+ @next_page_token = nil
24
25
  @current_page = 1
25
26
  end
26
27
 
27
28
  def search(keyword, options={})
28
- @current_page = options[:page].nil? ? 1 : options[:page]
29
29
  @keyword = keyword
30
30
  stdout = open(init_query_url).read()
31
+ get_next_page_token(stdout)
31
32
  AppParser.new(stdout).parse
32
33
  end
33
34
 
34
35
  def next_page()
35
- @current_page = @current_page + 1
36
- search @keyword, { :page => @current_page }
36
+ @current_page += 1
37
+ search @keyword
37
38
  end
38
39
 
39
40
  private
@@ -44,10 +45,18 @@ module GooglePlaySearch
44
45
  query_url << "c=" << @search_condition[:category] << "&"
45
46
  query_url << "hl=" << @search_condition[:language] << "&"
46
47
  query_url << "price=" << @search_condition[:price] << "&"
47
- query_url << "safe=" << @search_condition[:safe_search] << "&"
48
- query_url << "sort=" << @search_condition[:sort_by] << "&"
49
- start = (@current_page - 1) * @search_condition[:per_page_num]
50
- query_url << "start=#{start}&num=#{@search_condition[:per_page_num]}"
48
+ query_url << "rating=" << @search_condition[:rating] << "&"
49
+ #query_url << "safe=" << @search_condition[:safe_search] << "&"
50
+ #query_url << "sort=" << @search_condition[:sort_by] << "&"
51
+ query_url << "start=0&num=0"
52
+ if @next_page_token
53
+ query_url << "&pagTok=#{@next_page_token}"
54
+ end
55
+ query_url
56
+ end
57
+
58
+ def get_next_page_token(response_body)
59
+ @next_page_token = response_body.match(/(GAEi+.+:S:.{11})\\42/)[1][-22..-1]
51
60
  end
52
61
  end
53
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_play_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-25 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri