google_play_reviews 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +2 -0
- data/bin/google_play_reviews +38 -0
- data/google_play_reviews.gemspec +26 -0
- data/lib/google_play_reviews/entry.rb +12 -0
- data/lib/google_play_reviews/fetcher.rb +62 -0
- data/lib/google_play_reviews/version.rb +3 -0
- data/lib/google_play_reviews.rb +24 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db483269bf262a26e1a83f9cdaee32d16d33667b
|
4
|
+
data.tar.gz: 0c9b44e55cc34b4fbcbd82b88f6659a2f71fa6f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 702613c6a54a0228f803652e3d352f1c1e19c7aa0773c350dc5df4445daa195ec568aec397f709e3d830700a3eb30f55c3c6cdfc21c4b0c15214bd092d6ed4e8
|
7
|
+
data.tar.gz: 69fbd311bf2af46c6b5f1cc3f4caa257da4d2c47afb31501096e3c991e6e8c0c395848a0310d2ea694afbce20ea9a4d3d77038b18685f9f231e4807f2c688226
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Weihu Chen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# GooglePlayReviews
|
2
|
+
|
3
|
+
Fetch App reviews from Google Play.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'google_play_reviews'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install google_play_reviews
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Console command:
|
24
|
+
|
25
|
+
google_play_reviews [options] APP_ID
|
26
|
+
-s, --sort-order [VALUE] Sort order: 'newest'(default), 'rating' or 'helpfulness'
|
27
|
+
-p, --page [VALUE] Page number (start from 0)
|
28
|
+
-v, --version Display the current version
|
29
|
+
|
30
|
+
For example:
|
31
|
+
|
32
|
+
$ google_play_reviews -s helpfulness -p 2 com.google.android.googlequicksearchbox
|
33
|
+
------------------------------
|
34
|
+
review_id: gp:AOqpTOH34XsWVlMNiEIo7jarmgFNXbcyMz46Q5zgPaPvhrynruzQ-l98_3lOp10xMSJdkQxgK59F427eGnjCNA
|
35
|
+
author_name: ウルフハウンド
|
36
|
+
author_url: https://play.google.com/store/people/details?id=103315480914346702702
|
37
|
+
author_image_url: https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48
|
38
|
+
review_body: おかしい ブクマしたラベルに名前がつかない。編集でなんどつけても消える
|
39
|
+
rating: 2
|
40
|
+
review_date_string: 2015年3月4日
|
41
|
+
review_url: https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox&reviewId=Z3A6QU9xcFRPSDM0WHNXVmxNTmlFSW83amFybWdGTlhiY3lNejQ2UTV6Z1BhUHZocnlucnV6US1sOThfM2xPcDEweE1TSmRrUXhnSzU5RjQyN2VHbmpDTkE
|
42
|
+
------------------------------
|
43
|
+
review_id: gp:AOqpTOFNTB4yhD3mw8mXSu6KBhFofPHrYhI2yoEWfuQTalPKG-4JO_5ZSnYW2nE3jJS7t0RtU1pzrsgwpnzVsQ
|
44
|
+
author_name: 西上香奈
|
45
|
+
author_url: https://play.google.com/store/people/details?id=116289340209306231792
|
46
|
+
author_image_url: https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48
|
47
|
+
review_body: 何これ⁉ ググれないじゃん!早く直してよ!
|
48
|
+
rating: 1
|
49
|
+
review_date_string: 2015年3月6日
|
50
|
+
review_url: https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox&reviewId=Z3A6QU9xcFRPRk5UQjR5aEQzbXc4bVhTdTZLQmhGb2ZQSHJZaEkyeW9FV2Z1UVRhbFBLRy00Sk9fNVpTbllXMm5FM2pKUzd0MFJ0VTFwenJzZ3dwbnpWc1E
|
51
|
+
------------------------------
|
52
|
+
...
|
53
|
+
|
54
|
+
Or use it in ruby projects:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
GooglePlayReviews.fetch(app_id, options)
|
58
|
+
# Options:
|
59
|
+
# :sort_order (:newest, :rating, :helpfulness)
|
60
|
+
# :page (start from 0)
|
61
|
+
```
|
62
|
+
|
63
|
+
This will return the review entries. See [lib/google_play_reviews/entry.rb](lib/google_play_reviews/entry.rb)
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
+
|
5
|
+
require "optparse"
|
6
|
+
require "google_play_reviews"
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: google_play_reviews [options] APP_ID"
|
11
|
+
|
12
|
+
opts.on("-s [VALUE]", "--sort-order [VALUE]", "Sort order: 'newest'(default), 'rating' or 'helpfulness'") do |sort_order|
|
13
|
+
puts "Invalid sort-order." unless GooglePlayReviews.invalid_sort_order?(sort_order.to_sym)
|
14
|
+
options[:sort_order] = GooglePlayReviews::SortOrder[sort_order.to_sym]
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-p [VALUE]", "--page [VALUE]", "Page number (start from 0)") do |page|
|
18
|
+
options[:page] = page
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-v", "--version", "Display the current version") do
|
22
|
+
puts "command_timer " + GooglePlayReviews::VERSION
|
23
|
+
exit 0
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
opts.parse!
|
28
|
+
|
29
|
+
(ARGV[0] = '-h'; opts.parse!) unless ARGV[0]
|
30
|
+
|
31
|
+
entries = GooglePlayReviews.fetch(ARGV[0], options)
|
32
|
+
if entries.any?
|
33
|
+
puts "------------------------------"
|
34
|
+
entries.each do |entry|
|
35
|
+
puts entry
|
36
|
+
puts "------------------------------"
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'google_play_reviews/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "google_play_reviews"
|
8
|
+
spec.version = GooglePlayReviews::VERSION
|
9
|
+
spec.authors = ["Weihu Chen"]
|
10
|
+
spec.email = ["cctiger36@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Fetch App reviews from Google Play.}
|
13
|
+
spec.description = %q{Fetch App reviews from Google Play.}
|
14
|
+
spec.homepage = "https://github.com/cctiger36/google_play_reviews"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "nokogiri", "~> 1.6"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module GooglePlayReviews
|
2
|
+
class Entry
|
3
|
+
attr_accessor :review_id, :author_name, :author_url, :author_image_url,
|
4
|
+
:review_body, :rating, :review_date_string, :review_url
|
5
|
+
|
6
|
+
def to_s
|
7
|
+
instance_variables.map do |v|
|
8
|
+
"#{v.to_s.sub(/^@/, '')}: #{instance_variable_get(v)}"
|
9
|
+
end.join("\n")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "json"
|
2
|
+
require "uri"
|
3
|
+
require "net/http"
|
4
|
+
require "nokogiri"
|
5
|
+
require "openssl"
|
6
|
+
|
7
|
+
module GooglePlayReviews
|
8
|
+
class Fetcher
|
9
|
+
GOOGLE_PLAY_ROOT_URL = "https://play.google.com"
|
10
|
+
GET_REVIEWS_URL = "https://play.google.com/store/getreviews"
|
11
|
+
|
12
|
+
attr_accessor :app_id, :options
|
13
|
+
|
14
|
+
def fetch_entries(app_id, options = {})
|
15
|
+
@app_id = app_id
|
16
|
+
@options = options
|
17
|
+
html = fetch_html_from_google_play
|
18
|
+
extract_entries(html)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def fetch_html_from_google_play
|
23
|
+
uri = URI.parse(GET_REVIEWS_URL)
|
24
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
25
|
+
http.use_ssl = true
|
26
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
27
|
+
request = Net::HTTP::Post.new(uri.path)
|
28
|
+
request.set_form_data({
|
29
|
+
id: app_id,
|
30
|
+
reviewSortOrder: @options[:sort_order],
|
31
|
+
reviewType: 1,
|
32
|
+
pageNum: @options[:page]
|
33
|
+
})
|
34
|
+
response = http.start do |h|
|
35
|
+
h.request(request)
|
36
|
+
end
|
37
|
+
JSON.parse(response.body[5..-1])[0][2]
|
38
|
+
end
|
39
|
+
|
40
|
+
def extract_entries(html)
|
41
|
+
entries = []
|
42
|
+
doc = Nokogiri::HTML(html, nil, 'utf-8')
|
43
|
+
review_nodes = doc.css(".single-review")
|
44
|
+
review_nodes.each do |node|
|
45
|
+
review_id = node.css(".review-header").first["data-reviewid"]
|
46
|
+
entry = Entry.new
|
47
|
+
entry.review_id = review_id.strip
|
48
|
+
if node.css(".author-name a").first
|
49
|
+
entry.author_name = node.css(".author-name a").first.content
|
50
|
+
entry.author_url = GOOGLE_PLAY_ROOT_URL + node.css(".author-name a").first["href"]
|
51
|
+
entry.author_image_url = node.css(".author-image").first["src"]
|
52
|
+
end
|
53
|
+
entry.review_body = node.css(".review-body").first.text.strip.sub(/ 全文を表示$/, '')
|
54
|
+
entry.rating = node.css(".current-rating").first["style"].gsub(/[^0-9]/, '').to_i / 20
|
55
|
+
entry.review_date_string = node.css(".review-date").first.text
|
56
|
+
entry.review_url = GOOGLE_PLAY_ROOT_URL + node.css("a.reviews-permalink").first["href"]
|
57
|
+
entries << entry
|
58
|
+
end
|
59
|
+
entries
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "google_play_reviews/version"
|
2
|
+
require "google_play_reviews/entry"
|
3
|
+
require "google_play_reviews/fetcher"
|
4
|
+
|
5
|
+
module GooglePlayReviews
|
6
|
+
SortOrder = {
|
7
|
+
newest: 0,
|
8
|
+
rating: 1,
|
9
|
+
helpfulness: 4
|
10
|
+
}
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def fetch(app_id, options = {})
|
14
|
+
return unless app_id
|
15
|
+
options[:sort_order] ||= SortOrder[:newest]
|
16
|
+
options[:page] ||= 0
|
17
|
+
Fetcher.new.fetch_entries(app_id, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def invalid_sort_order?(key)
|
21
|
+
SortOrder.keys.include?(key)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_play_reviews
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Weihu Chen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
description: Fetch App reviews from Google Play.
|
70
|
+
email:
|
71
|
+
- cctiger36@gmail.com
|
72
|
+
executables:
|
73
|
+
- google_play_reviews
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/google_play_reviews
|
85
|
+
- google_play_reviews.gemspec
|
86
|
+
- lib/google_play_reviews.rb
|
87
|
+
- lib/google_play_reviews/entry.rb
|
88
|
+
- lib/google_play_reviews/fetcher.rb
|
89
|
+
- lib/google_play_reviews/version.rb
|
90
|
+
homepage: https://github.com/cctiger36/google_play_reviews
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.6
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Fetch App reviews from Google Play.
|
114
|
+
test_files: []
|