Class: FiresideFinder::Scraper
- Inherits:
-
Object
- Object
- FiresideFinder::Scraper
- Defined in:
- lib/fireside-finder/scraper.rb
Instance Attribute Summary collapse
-
#geoaddress ⇒ Object
Returns the value of attribute geoaddress.
-
#page ⇒ Object
Returns the value of attribute page.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#specific_event ⇒ Object
Returns the value of attribute specific_event.
-
#user_input ⇒ Object
Returns the value of attribute user_input.
Class Method Summary collapse
Instance Attribute Details
#geoaddress ⇒ Object
Returns the value of attribute geoaddress.
9 10 11 |
# File 'lib/fireside-finder/scraper.rb', line 9 def geoaddress @geoaddress end |
#page ⇒ Object
Returns the value of attribute page.
9 10 11 |
# File 'lib/fireside-finder/scraper.rb', line 9 def page @page end |
#parsed ⇒ Object
Returns the value of attribute parsed.
9 10 11 |
# File 'lib/fireside-finder/scraper.rb', line 9 def parsed @parsed end |
#specific_event ⇒ Object
Returns the value of attribute specific_event.
9 10 11 |
# File 'lib/fireside-finder/scraper.rb', line 9 def specific_event @specific_event end |
#user_input ⇒ Object
Returns the value of attribute user_input.
9 10 11 |
# File 'lib/fireside-finder/scraper.rb', line 9 def user_input @user_input end |
Class Method Details
.scrape_list(user_input) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fireside-finder/scraper.rb', line 11 def self.scrape_list(user_input) coords = FiresideFinder::Geocode.geosearch(user_input) @page = HTTParty.get("http://us.battle.net/hearthstone/en/fireside-gatherings?lat=#{coords[0]}&lng=#{coords[1]}") @parsed = Nokogiri::HTML(@page) @parsed.css('.meetups-event-table__row:not(:first-child)').each do |event_detail| new_gathering = FiresideFinder::Gathering.new new_gathering.name = event_detail.css('.meetups-event-table__cell__name').children.text new_gathering.city = event_detail.css('.meetups-event-table__cell__city').text new_gathering.date = event_detail.css('.meetups-event-table__cell--time').text.strip event_link = event_detail.attribute('href') new_gathering.details_link = "http://us.battle.net#{event_link}" new_gathering.save end end |
.scrape_specific(specific_event) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fireside-finder/scraper.rb', line 27 def self.scrape_specific(specific_event) @page = HTTParty.get("#{specific_event.details_link}") @parsed = Nokogiri::HTML(@page) FiresideFinder::Gathering.reset new_gathering = FiresideFinder::Gathering.new new_gathering.name = @parsed.css('.meetup-header__title').text.strip new_gathering.venue = @parsed.css('.location-address').css('h4').text new_gathering.address = @parsed.css('.location-address').css('p').text new_gathering.datetime = @parsed.css('.details-start-date').text.strip description = @parsed.css('.description:first-of-type').css('p:first-of-type').text.gsub! "\r" "\n", "" if description != nil new_gathering.description = @parsed.css('.description:first-of-type').css('p:first-of-type').text.gsub! "\r" "\n", "" end new_gathering.directions = @parsed.css('.map-container span').css('a').map { |link| link['href'] }[0] new_gathering.save end |