Class: AppListScraper

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

Class Method Summary collapse

Class Method Details

.scrape_shopify_appsObject

returns an array of Shopify App hashes



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

def self.scrape_shopify_apps # returns an array of Shopify App hashes
  html = open('https://asoft.co/shopify-apps/most-reviewed')
  index = Nokogiri::HTML(html)
  app_array = []
  index.css('tr').each do |row|
    unless row == index.css('tr')[0] # Skip the first row (headers)
      hash = {}
      hash[:name] = row.css('td').css('a').first.text
      hash[:url] = row.css('td a').first.attributes["href"].text
      hash[:category] = row.css('td').last.text
      hash[:developer_name] = row.css('td').css('a').last.text
      hash[:developer_url] = row.css('td').css('a').last["href"]
      app_array << hash
    end
  end
  app_array
end