google_play_search 0.0.18 → 0.0.19

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: 3936d85781012b34ad94b30711567e84818dd56e
4
- data.tar.gz: c7a5fd9581342a0776f8b88a3f1b8ad583a56ded
3
+ metadata.gz: 7c31f3cf4e9a775da1b7c2e320d08d01e484b04f
4
+ data.tar.gz: ec97837fac6f9caad0ff85b511bb1a138f7f9ee9
5
5
  SHA512:
6
- metadata.gz: 693303ad608a6a206be2e7bd31d2a424d0ad70f7936847efa67285e2fa11ec22d5aa697bee89b5f9d821655d43a502f7fcb1ecbd9eb3056da0323c67f749fd68
7
- data.tar.gz: 32db769675576635626ab8b536663fb4688a9a5df3078f4b69071123b78bab5db8b1008b0731f6acbc4330141af1ea2d0a8b09e2c83be25d34166cd0eb22f8e7
6
+ metadata.gz: d5aabca14c35fbcdea7afbba053531c57d19e500cb8b618e06cbad1d796360d2f1df8f152f9449730a3289cb103084d1630d13788968a1221af7e321344b4ca3
7
+ data.tar.gz: 28bdf3cef41dc874714b830a250b629e5a092540db88e9478bb4ababfd7090098c415a83711bf631a44497d19565d79ba7da5360c9857ef54ad2a6e66164509b
@@ -1,4 +1,3 @@
1
- require 'open-uri'
2
1
  require 'nokogiri'
3
2
  require File.expand_path(File.dirname(__FILE__) + '/review')
4
3
 
@@ -12,7 +11,7 @@ module GooglePlaySearch
12
11
  :long_description
13
12
 
14
13
  def get_all_details()
15
- html = open(self.url).read()
14
+ html = HTTPClient.new.get(self.url).body
16
15
  google_play_html = Nokogiri::HTML(html)
17
16
 
18
17
  self.version = get_version(google_play_html)
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'nokogiri'
3
- require 'open-uri'
4
3
  require 'cgi'
5
4
  require File.expand_path(File.dirname(__FILE__) + '/app_parser')
6
5
 
@@ -10,13 +9,11 @@ module GooglePlaySearch
10
9
 
11
10
  $GOOGLE_PLAY_STORE_BASE_URL = "https://play.google.com"
12
11
 
13
- GOOGLE_PLAY_BASE_SEARCH_URL = $GOOGLE_PLAY_STORE_BASE_URL + "/store/search?q="
12
+ GOOGLE_PLAY_BASE_SEARCH_URL = $GOOGLE_PLAY_STORE_BASE_URL + "/store/search"
14
13
 
15
14
  DEFAULT_SEARCH_CONDITION = {:language => "en",
16
15
  :category => "apps",
17
- #:per_page_num => 20,
18
16
  :price => "0",
19
- #:safe_search => "0",
20
17
  :rating => "0"}
21
18
 
22
19
  def initialize(search_condition = DEFAULT_SEARCH_CONDITION)
@@ -27,9 +24,9 @@ module GooglePlaySearch
27
24
 
28
25
  def search(keyword, options={})
29
26
  @keyword = keyword
30
- stdout = open(init_query_url).read()
31
- get_next_page_token(stdout)
32
- AppParser.new(stdout).parse
27
+ page = HTTPClient.new.get(GOOGLE_PLAY_BASE_SEARCH_URL, query_params).body
28
+ get_next_page_token(page)
29
+ AppParser.new(page).parse
33
30
  end
34
31
 
35
32
  def next_page()
@@ -38,21 +35,20 @@ module GooglePlaySearch
38
35
  end
39
36
 
40
37
  private
41
- def init_query_url
42
- query_url = ""
43
- query_url << GOOGLE_PLAY_BASE_SEARCH_URL
44
- query_url << CGI.escape(@keyword) << "&"
45
- query_url << "c=" << @search_condition[:category] << "&"
46
- query_url << "hl=" << @search_condition[:language] << "&"
47
- query_url << "price=" << @search_condition[:price] << "&"
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"
38
+ def query_params
39
+ params = {
40
+ 'q' => @keyword,
41
+ 'c' => @search_condition[:category],
42
+ 'hl' => @search_condition[:language],
43
+ 'price' => @search_condition[:price],
44
+ 'rating' => @search_condition[:rating],
45
+ 'start' => 0,
46
+ 'num' => 0
47
+ }
52
48
  if @next_page_token
53
- query_url << "&pagTok=#{@next_page_token}"
49
+ params['pagTok'] = @next_page_token
54
50
  end
55
- query_url
51
+ params
56
52
  end
57
53
 
58
54
  def get_next_page_token(response_body)
@@ -1,3 +1,4 @@
1
+ require 'httpclient'
1
2
  require 'google_play_search/search'
2
3
  module GooglePlaySearch
3
- end
4
+ 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.18
4
+ version: 0.0.19
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-12-29 00:00:00.000000000 Z
11
+ date: 2016-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httpclient
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
83
  version: '0'
70
84
  requirements: []
71
85
  rubyforge_project:
72
- rubygems_version: 2.5.0
86
+ rubygems_version: 2.4.5
73
87
  signing_key:
74
88
  specification_version: 4
75
89
  summary: google play market search