Class: Trendster::Scraper
- Inherits:
-
Object
- Object
- Trendster::Scraper
- Defined in:
- lib/trendster/scraper.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#audience ⇒ Object
Returns the value of attribute audience.
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Attribute Details
#audience ⇒ Object
Returns the value of attribute audience.
6 7 8 |
# File 'lib/trendster/scraper.rb', line 6 def audience @audience end |
#date ⇒ Object
Returns the value of attribute date.
6 7 8 |
# File 'lib/trendster/scraper.rb', line 6 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/trendster/scraper.rb', line 6 def description @description end |
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'lib/trendster/scraper.rb', line 6 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/trendster/scraper.rb', line 6 def name @name end |
Class Method Details
.all ⇒ Object
8 9 10 |
# File 'lib/trendster/scraper.rb', line 8 def self.all @@all end |
.scrape_library_page ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/trendster/scraper.rb', line 12 def self.scrape_library_page url_endings = [] index_url = "http://cuyahogalibrary.org/Events/Event-Results.aspx" index_doc = Nokogiri::HTML(open(index_url)) index_doc.css("article.sixcol").each do |event| url_endings << event.css("a")[0]['href'] end event_urls = [] url_endings.each do |url_ending| event_urls << "http://cuyahogalibrary.org" + url_ending end event_doc_array = [] event_urls.each do |event_url| event_doc = Nokogiri::HTML(open(event_url)) event_doc_array << event_doc end all_array = [] event_doc_array.each do |event_doc| all_array << { name: event_doc.css("h3").text, description: event_doc.css("p.one-large-content").text || "", date: event_doc.css("strong").text, location: event_doc.css("p").css("a").text, audience: event_doc.css("p").text.match("Adults") || event_doc.css("p").text.match("Children") } end all_array end |