Class: ScraperGooglePlay::App
- Defined in:
- lib/scraper_google_play/app.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#android_version ⇒ Object
Returns the value of attribute android_version.
-
#android_version_text ⇒ Object
Returns the value of attribute android_version_text.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#description ⇒ Object
Returns the value of attribute description.
-
#developer ⇒ Object
Returns the value of attribute developer.
-
#email ⇒ Object
Returns the value of attribute email.
-
#genre_id ⇒ Object
Returns the value of attribute genre_id.
-
#genre_text ⇒ Object
Returns the value of attribute genre_text.
-
#package_name ⇒ Object
Returns the value of attribute package_name.
-
#score ⇒ Object
Returns the value of attribute score.
-
#screen_shots ⇒ Object
writeonly
Sets the attribute screen_shots.
-
#size ⇒ Object
Returns the value of attribute size.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
-
#vide ⇒ Object
Returns the value of attribute vide.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(package_name, options = {}) ⇒ App
constructor
A new instance of App.
- #similar_app ⇒ Object
Methods inherited from Base
#exist?, #list_packname_with_page
Constructor Details
#initialize(package_name, options = {}) ⇒ App
Returns a new instance of App.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/scraper_google_play/app.rb', line 6 def initialize(package_name, = {}) @package_name = package_name @agent = Mechanize.new @query = { id: package_name, }.merge().to_query unless exist?("#{ScraperGooglePlay::APPURL}?#{@query}") @page = nil else @page = @agent.get("#{ScraperGooglePlay::APPURL}?#{@query}") end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def address @address end |
#android_version ⇒ Object
Returns the value of attribute android_version.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def android_version @android_version end |
#android_version_text ⇒ Object
Returns the value of attribute android_version_text.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def android_version_text @android_version_text end |
#app_name ⇒ Object
Returns the value of attribute app_name.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def app_name @app_name end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def description @description end |
#developer ⇒ Object
Returns the value of attribute developer.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def developer @developer end |
#email ⇒ Object
Returns the value of attribute email.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def email @email end |
#genre_id ⇒ Object
Returns the value of attribute genre_id.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def genre_id @genre_id end |
#genre_text ⇒ Object
Returns the value of attribute genre_text.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def genre_text @genre_text end |
#package_name ⇒ Object
Returns the value of attribute package_name.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def package_name @package_name end |
#score ⇒ Object
Returns the value of attribute score.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def score @score end |
#screen_shots=(value) ⇒ Object
Sets the attribute screen_shots
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def screen_shots=(value) @screen_shots = value end |
#size ⇒ Object
Returns the value of attribute size.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def size @size end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def version @version end |
#vide ⇒ Object
Returns the value of attribute vide.
2 3 4 |
# File 'lib/scraper_google_play/app.rb', line 2 def vide @vide end |
Instance Method Details
#info ⇒ Object
21 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 |
# File 'lib/scraper_google_play/app.rb', line 21 def info return {} unless @page detailsInfo = @page.at('.details-info') additionalInfo = @page.search('.details-section-contents') mainGenre = detailsInfo.at('.category') android_version_text = @page.at('.details-section-contents div.content[itemprop="operatingSystems"]').text().strip() @app_info = { name: name, logo: logo, screen_shots: screen_shots, developer: detailsInfo.at('span[itemprop="name"]').text, address: @page.at('.content.physical-address').try(:text), email: @page.at('.content.contains-text-link .dev-link[href^="mailto:"]') ? @page.at('.content.contains-text-link .dev-link[href^="mailto:"]').attr('href').split(':')[-1] : nil , title: detailsInfo.at('.document-title').text.strip, genre_text: mainGenre.text().strip, genre_id: mainGenre.attr('href').split('/')[4], version: @page.at('.details-section-contents div.content[itemprop="softwareVersion"]') ? @page.at('.details-section-contents div.content[itemprop="softwareVersion"]').text().strip() : nil, description: @page.at('.details-section-contents div[itemprop=description] div').text().gsub(/<\/p>/, '\n</p>'), android_version_text: android_version_text, android_version: normalizeAndroidVersion(android_version_text), contentRating: @page.at('.details-section-contents div.content[itemprop="contentRating"]').text().strip(), size: @page.at('.details-section-contents div.content[itemprop="fileSize"]').try(:text), video: @page.at('.screenshots span.preview-overlay-container[data-video-url]') ? @page.at('.screenshots span.preview-overlay-container[data-video-url]').attr('data-video-url') : nil, score: @page.at('.rating-box div.score').text().to_s.gsub(',', '.'), } end |
#similar_app ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/scraper_google_play/app.rb', line 51 def similar_app return nil unless @page apps = [] recommendation = @page.at(".recommendation") recommendation.search(".cards id-card-list .card.apps").each do |app| apps << app.attr('data-docid') end apps end |