Class: StoreApi::GooglePlay::Apps::Details
- Inherits:
-
Object
- Object
- StoreApi::GooglePlay::Apps::Details
- Includes:
- Request
- Defined in:
- lib/store_api/google_play/apps/details.rb
Overview
google play detail class
Constant Summary collapse
- @@path =
'/store/apps/details'
Constants included from Request
Instance Attribute Summary collapse
-
#badge_title ⇒ Object
Returns the value of attribute badge_title.
-
#category ⇒ Object
Returns the value of attribute category.
-
#category_id ⇒ Object
Returns the value of attribute category_id.
-
#category_url ⇒ Object
Returns the value of attribute category_url.
-
#content_rating ⇒ Object
Returns the value of attribute content_rating.
-
#cover_image ⇒ Object
Returns the value of attribute cover_image.
-
#date_published ⇒ Object
Returns the value of attribute date_published.
-
#description ⇒ Object
Returns the value of attribute description.
-
#developer ⇒ Object
Returns the value of attribute developer.
-
#developer_address ⇒ Object
Returns the value of attribute developer_address.
-
#developer_links ⇒ Object
Returns the value of attribute developer_links.
-
#developer_url ⇒ Object
Returns the value of attribute developer_url.
-
#downloads ⇒ Object
Returns the value of attribute downloads.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#google_plus ⇒ Object
Returns the value of attribute google_plus.
-
#id ⇒ Object
Returns the value of attribute id.
-
#operating_system ⇒ Object
Returns the value of attribute operating_system.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rating_count ⇒ Object
Returns the value of attribute rating_count.
-
#rating_map ⇒ Object
Returns the value of attribute rating_map.
-
#rating_score ⇒ Object
Returns the value of attribute rating_score.
-
#rating_value ⇒ Object
Returns the value of attribute rating_value.
-
#screenshot ⇒ Object
Returns the value of attribute screenshot.
-
#software_version ⇒ Object
Returns the value of attribute software_version.
-
#title ⇒ Object
Returns the value of attribute title.
-
#video_url ⇒ Object
Returns the value of attribute video_url.
-
#whatsnew ⇒ Object
Returns the value of attribute whatsnew.
Instance Method Summary collapse
-
#initialize(id, lang = nil, proxy = nil, header = nil) ⇒ Details
constructor
initialize.
Methods included from Request
Constructor Details
#initialize(id, lang = nil, proxy = nil, header = nil) ⇒ Details
initialize
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/store_api/google_play/apps/details.rb', line 22 def initialize(id,lang=nil,proxy=nil,header=nil) params = {'id' => id } if !lang.nil? params['hl'] = lang end begin html = get(StoreApi::GooglePlay::HOST,@@path,params,StoreApi::GooglePlay::HTTPS,proxy,header) doc = Nokogiri::HTML(html,nil,'utf-8') @id = id content_xpath = "id('body-content')" doc.xpath("#{content_xpath}//div[@class='details-info']").each do |node| # puts node.methods @title = node.css('.document-title').text.strip @cover_image = node.css('.cover-image').attribute('src').value @developer = node.css('.primary').text.strip @developer_url = node.css('.primary').attribute('href').value @category = node.css('.category').text.strip @category_url = node.css('.category').attribute('href').value @category_id = node.css('.category').attribute('href').value.split("/")[4] @badge_title = node.css('.badge-title').text.strip @price = node.xpath("//*[@class='price buy id-track-click']//*[@itemprop='price']/@content").text end thumbnails_xpath = "#{content_xpath}//div[@class='thumbnails']" @screenshot = doc.xpath("#{thumbnails_xpath}/img").map {|node| node.attribute('src').value } @video_url = doc.xpath("#{thumbnails_xpath}/span[@class='details-trailer']/span[@class='preview-overlay-container']/@data-video-url").text @description = doc.xpath("#{content_xpath}//div[@itemprop='description']").to_html @rating_score = doc.xpath("#{content_xpath}//div[@class='rating-box']//div[@class='score']").text = "#{content_xpath}//div[@class='rating-box']" @rating_value = doc.xpath("#{}//*[@itemprop='ratingValue']/@content").text @rating_count = doc.xpath("#{}//*[@itemprop='ratingCount']/@content").text @rating_map = {} doc.xpath("#{}//div[@class='rating-histogram']/div").each do |node| star_num = node.css(".bar-label").text.strip @rating_map[star_num.to_i] = node.css(".bar-number").text.gsub(',','') end @whatsnew = doc.xpath("#{content_xpath}//div[@class='details-section whatsnew']//div[@class='recent-change']").text = "#{content_xpath}//div[@class='details-section metadata']//div[@class='meta-info']" @date_published = doc.xpath("#{}//div[@itemprop='datePublished']").text @file_size = doc.xpath("#{}//div[@itemprop='fileSize']").text @file_size = !@file_size.nil? ? @file_size.strip : nil @downloads = doc.xpath("#{}//div[@itemprop='numDownloads']").text @downloads = !@downloads.nil? ? @downloads.strip : nil @software_version = doc.xpath("#{}//div[@itemprop='softwareVersion']").text @software_version = !@software_version.nil? ? @software_version.strip : nil @operating_system = doc.xpath("#{}//div[@itemprop='operatingSystems']").text @operating_system = !@operating_system.nil? ? @operating_system.strip : nil @content_rating = doc.xpath("#{}//div[@itemprop='contentRating']").text @content_rating = !@content_rating.nil? ? @content_rating.strip : nil @developer_address = doc.xpath("#{}//div[@class='content physical-address']").text @developer_address = !@developer_address.nil? ? @developer_address.strip : nil @developer_links = [] doc.xpath("#{content_xpath}//div[@class='details-section metadata']//div[@class='content contains-text-link']/a[@class='dev-link']").each do |node| @developer_links.push({'text' => node.text,'link' => node.attribute('href').value}) end rescue => e puts e end end |
Instance Attribute Details
#badge_title ⇒ Object
Returns the value of attribute badge_title.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def badge_title @badge_title end |
#category ⇒ Object
Returns the value of attribute category.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def category @category end |
#category_id ⇒ Object
Returns the value of attribute category_id.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def category_id @category_id end |
#category_url ⇒ Object
Returns the value of attribute category_url.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def category_url @category_url end |
#content_rating ⇒ Object
Returns the value of attribute content_rating.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @content_rating end |
#cover_image ⇒ Object
Returns the value of attribute cover_image.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def cover_image @cover_image end |
#date_published ⇒ Object
Returns the value of attribute date_published.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def date_published @date_published end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def description @description end |
#developer ⇒ Object
Returns the value of attribute developer.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def developer @developer end |
#developer_address ⇒ Object
Returns the value of attribute developer_address.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def developer_address @developer_address end |
#developer_links ⇒ Object
Returns the value of attribute developer_links.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def developer_links @developer_links end |
#developer_url ⇒ Object
Returns the value of attribute developer_url.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def developer_url @developer_url end |
#downloads ⇒ Object
Returns the value of attribute downloads.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def downloads @downloads end |
#file_size ⇒ Object
Returns the value of attribute file_size.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def file_size @file_size end |
#google_plus ⇒ Object
Returns the value of attribute google_plus.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def google_plus @google_plus end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def id @id end |
#operating_system ⇒ Object
Returns the value of attribute operating_system.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @operating_system end |
#price ⇒ Object
Returns the value of attribute price.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def price @price end |
#rating_count ⇒ Object
Returns the value of attribute rating_count.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @rating_count end |
#rating_map ⇒ Object
Returns the value of attribute rating_map.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @rating_map end |
#rating_score ⇒ Object
Returns the value of attribute rating_score.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @rating_score end |
#rating_value ⇒ Object
Returns the value of attribute rating_value.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def @rating_value end |
#screenshot ⇒ Object
Returns the value of attribute screenshot.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def screenshot @screenshot end |
#software_version ⇒ Object
Returns the value of attribute software_version.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def software_version @software_version end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def title @title end |
#video_url ⇒ Object
Returns the value of attribute video_url.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def video_url @video_url end |
#whatsnew ⇒ Object
Returns the value of attribute whatsnew.
11 12 13 |
# File 'lib/store_api/google_play/apps/details.rb', line 11 def whatsnew @whatsnew end |