Class: AppReviewScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app_reviews/app_review_scraper.rb

Class Method Summary collapse

Class Method Details

.scrape_app_metadata(app) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/shopify_app_reviews/app_review_scraper.rb', line 22

def self.(app)
  html = open(app.url+"/reviews")
  index = Nokogiri::HTML(html)
  app.description = index.css('.ui-app-store-hero__description-text').text
  overall_rating = index.css('.ui-star-rating__rating').first.text
  app.overall_rating = overall_rating

  html2 = open(app.url)
  index2 = Nokogiri::HTML(html2)
  dev_contact = index2.css('li.app-support-list__item span').children.find do |li|
    li.text.strip if li.text.include?("@")
  end
  app.developer_contact = dev_contact.text
end

.scrape_app_reviews(app) ⇒ Object

returns an array of AppReview hashes



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shopify_app_reviews/app_review_scraper.rb', line 6

def self.scrape_app_reviews(app) # returns an array of AppReview hashes
  html = open(app.url+"/reviews")
  index = Nokogiri::HTML(html)
  review_array = []
  index.css('.review-listing').each do |review|
    hash = {}
    hash[:title] = review.css('.review-listing-header__text').text.strip
    hash[:body] = review.css('.review-content').css('p').text
    hash[:date] = review.css('.review-metadata__item')[1].css('div').children.last.text.strip
    hash[:rating] = review.css('.ui-star-rating').css('div.ui-star-rating__text').text
    hash[:app] = app
    review_array << hash
  end
  review_array
end