Class: Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/top_free_apps_itunes/scraper.rb

Class Method Summary collapse

Class Method Details

.scrape_app_details(app) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/top_free_apps_itunes/scraper.rb', line 17

def self.scrape_app_details(app)

    html = open(app.url)
    doc = Nokogiri::HTML(html)
    app.developer = doc.css(".l-row dd")[0].text.strip
    app.category = doc.css(".l-row dd")[2].text.strip
    app.rating = doc.css(".l-row .we-customer-ratings__averages__display").text
    app.language = doc.css(".l-row dd")[4].text.strip
    app.size = doc.css(".l-row dd")[1].text.strip

end

.scrape_itunesObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/top_free_apps_itunes/scraper.rb', line 3

def self.scrape_itunes

    html = open("https://www.apple.com/itunes/charts/free-apps/")
    doc = Nokogiri::HTML(html)


    doc.css(".section-content li").each do |app_doc|
        title = app_doc.css("h3 a").text
        url = app_doc.css("h3 a").attr("href").value
        App.new(title, url)
    end

end