google_play_search 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e9859c59cc98d1d82cb88b40a65d4fcd722e323
4
- data.tar.gz: 4b0d77cd3b2eccc2f29a8dda94f3e9a1623f4d2f
3
+ metadata.gz: 709ead00b916ad6eaff79be0de305424ee308bd4
4
+ data.tar.gz: 529ad769f2982f2e7f8393e31fae250789e7e5da
5
5
  SHA512:
6
- metadata.gz: 74e44bea9e510f72fed18129817c3a7bb582d07000cf6bfe6eccaabb11bb078a36f524501aa6cbe5b072ef4026427149754887a2215be87baae7879e68780c99
7
- data.tar.gz: 469a0da05219097c0e9f40a8fa3f78e6dd4c1cea8f72222696a1a636f4b5151b16df49ba09ffa84c8a676c78ecca290c4d2d6e3058911f9df534fb107dbdf1c0
6
+ metadata.gz: e54671b641e25750a4897bdfcd8968e3310192782f409c4b5cf00d7ace592303ad3d74de8e129c6007f9b73d541863e540af7bd2e829fe8f94e292adab364928
7
+ data.tar.gz: 594ce6f2107e830edcc6ff03c70fcf9285074a1f939d58c4a202837b2ebbb11d46fd1df70f7d245e202a64bb39df575163edb1d0eba43e49cdb32bb5373cc248
@@ -1,8 +1,11 @@
1
1
  require 'nokogiri'
2
2
  require File.expand_path(File.dirname(__FILE__) + '/review')
3
+ require File.expand_path(File.dirname(__FILE__) + '/utils')
3
4
 
4
5
  module GooglePlaySearch
5
6
  class App
7
+ include GooglePlaySearch::Utils
8
+
6
9
  attr_accessor :id, :name, :url, :developer, :category, :logo_url,
7
10
  :short_description, :rating, :ratings_count, :reviews, :price,
8
11
  :count_5_star, :count_4_star, :count_3_star, :count_2_star, :count_1_star,
@@ -101,12 +104,13 @@ module GooglePlaySearch
101
104
 
102
105
  def get_reviews(google_play_html)
103
106
  reviews = []
104
- google_play_html.search("div[class='single-review']").each do |ele|
107
+ google_play_html.search("div[class='featured-review']").each do |ele|
105
108
  review = GooglePlaySearch::Review.new()
106
109
  review.author_name = ele.search("span[class='author-name']").first.content.strip
107
- review.author_avatar = ele.search("img[class='author-image']").first['src'].strip
110
+ review.author_avatar = get_image_url_from_style(
111
+ ele.search("span[class='responsive-img author-image']").first['style'].strip)
108
112
  review.review_title = ele.search("span[class='review-title']").first.content.strip
109
- review.review_content = ele.search("div[class='review-body']").children[2].content.strip
113
+ review.review_content = ele.search("div[class='review-text']").children[2].content.strip
110
114
  review.star_rating = ele.search("div[class='tiny-star star-rating-non-editable-container']").first['aria-label'].scan(/\d/).first.to_i
111
115
  reviews << review
112
116
  end
@@ -116,7 +120,7 @@ module GooglePlaySearch
116
120
  def get_screenshots(google_play_html)
117
121
  screenshots = []
118
122
  google_play_html.search("div[class='screenshot-align-inner'] img").each do |ele|
119
- screenshots << ele['src'].strip
123
+ screenshots << add_http_prefix(ele['src'].strip)
120
124
  end
121
125
  screenshots
122
126
  end
@@ -1,7 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/app')
2
+ require File.expand_path(File.dirname(__FILE__) + '/utils')
2
3
 
3
4
  module GooglePlaySearch
4
5
  class AppParser
6
+ include GooglePlaySearch::Utils
7
+
5
8
  SEARCH_APP_URL_END_SUFF = "&feature=search_result"
6
9
 
7
10
  def initialize(content)
@@ -31,7 +34,7 @@ module GooglePlaySearch
31
34
  end
32
35
 
33
36
  def get_logo_url(app_content)
34
- app_content.css("img.cover-image").first['src']
37
+ add_http_prefix(app_content.css("img.cover-image").first['src'])
35
38
  end
36
39
 
37
40
  def get_name(app_content)
@@ -0,0 +1,13 @@
1
+ module GooglePlaySearch::Utils
2
+ def add_http_prefix(url)
3
+ unless url.start_with?("http")
4
+ return "https:" + url
5
+ end
6
+ end
7
+
8
+ def get_image_url_from_style(url)
9
+ if url.start_with?("background-image:url(")
10
+ return url["background-image:url(".length..-2]
11
+ end
12
+ end
13
+ 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.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -105,6 +105,7 @@ files:
105
105
  - lib/google_play_search/app_parser.rb
106
106
  - lib/google_play_search/review.rb
107
107
  - lib/google_play_search/search.rb
108
+ - lib/google_play_search/utils.rb
108
109
  homepage: https://github.com/grantchen/google_play_search
109
110
  licenses:
110
111
  - MIT