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.
5 6 7 |
# File 'lib/trendster/scraper.rb', line 5 def audience @audience end |
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/trendster/scraper.rb', line 5 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/trendster/scraper.rb', line 5 def description @description end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/trendster/scraper.rb', line 5 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/trendster/scraper.rb', line 5 def name @name end |
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/trendster/scraper.rb', line 7 def self.all @@all end |
.scrape_library_page ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trendster/scraper.rb', line 11 def self.scrape_library_page all_array = [] index_url = "http://cuyahogalibrary.org/Events/Event-Results.aspx" index_doc = Nokogiri::HTML(open(index_url)) index_doc.css("article.sixcol").each do |event| event_url = "http://cuyahogalibrary.org" + event.css("a")[0]['href'] event_doc = Nokogiri::HTML(open(event_url)) 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") || event_doc.css("p").text.match("Families") || event_doc.css("p").text.match("Teens") || event_doc.css("p").text.match("All") || event_doc.css("p").text.match("Preschool") } end all_array end |