Class: NYCTheaterDiscounts::Scraper

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#lowest_priceObject

Returns the value of attribute lowest_price.



6
7
8
# File 'lib/nyc_theater_discounts/scraper.rb', line 6

def lowest_price
  @lowest_price
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/nyc_theater_discounts/scraper.rb', line 6

def name
  @name
end

#showsObject

Returns the value of attribute shows.



6
7
8
# File 'lib/nyc_theater_discounts/scraper.rb', line 6

def shows
  @shows
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/nyc_theater_discounts/scraper.rb', line 6

def url
  @url
end

Class Method Details

.load_BroadwayBoxObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/nyc_theater_discounts/scraper.rb', line 49

def self.load_BroadwayBox
  deals_page = Nokogiri::HTML(open('http://www.broadwaybox.com/shows/tickets/discounts/?v=b'))
  
  broadwaybox = NYCTheaterDiscounts::Vendor.new("BroadwayBox", "http://www.broadwaybox.com/shows/tickets/discounts/?v=b")

  deals_page.css("div.list-group.list-quebec a.list-group-item").each do |show|
 
    title = show.css('div.media-body div.event-title').text
    link = "http://www.broadwaybox.com" + show['href']

    show_page = Nokogiri::HTML(open(link))
    price = show_page.css("div.col-md-6 p.slat-title strong")[0].text
    price.slice!(/Tickets\sjust\s/)
    
    newshow = NYCTheaterDiscounts::Show.new(title, price, link)
    newshow.vendors << broadwaybox
    broadwaybox.shows << newshow
  end
end

.load_TheatermaniaObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/nyc_theater_discounts/scraper.rb', line 32

def self.load_Theatermania
  deals_page = Nokogiri::HTML(open('http://www.theatermania.com/new-york-city-theater/discount-tickets/'))
  
  theatermania = NYCTheaterDiscounts::Vendor.new("Theatermania", "http://www.theatermania.com/new-york-city-theater/discount-tickets/")

  deals_page.css("div#listings_right div#result div.list div.show.logo").each do |show|
 
    title = show.css('a.show-title span.show-name').text
    link = "http://www.theatermania.com/" + show.css('a.show-title')[0]['href']
    price = show.css("div strong").text
    
    newshow = NYCTheaterDiscounts::Show.new(title, price, link)
    newshow.vendors << theatermania
    theatermania.shows << newshow
  end
end

.load_TodayTixObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nyc_theater_discounts/scraper.rb', line 8

def self.load_TodayTix
  deals_page = Nokogiri::HTML(open('http://www.todaytix.com/us/nyc/shows/'))
  
  todaytix = NYCTheaterDiscounts::Vendor.new("TodayTix", "http://www.todaytix.com/us/nyc/shows/")

  deals_page.css("div.shows_hero_container a.heroTile.grid").each do |show|

    title = show.css('header span.title').text
    link = "http://www.todaytix.com/" + show['href']
    price = show['data-min-price']
    price = "$" + price.to_s

    if title.include?("Referral Program") != true && title.include?("Gift Cards") != true
      newshow = NYCTheaterDiscounts::Show.new(title, price, link)
      newshow.vendors << todaytix
      todaytix.shows << newshow
    end
    ##div.shows_hero_container a.heroTile.grid
    ##href
    ##data-min-price **add $**
    ##header span.title
  end
end