Class: Adventures::Scraper
- Inherits:
-
Object
- Object
- Adventures::Scraper
- Defined in:
- lib/adventures/scraper.rb
Instance Method Summary collapse
- #activity_url_creator(activity) ⇒ Object
- #gather_adventures(activity, state) ⇒ Object
- #get_page(activity, state) ⇒ Object
- #scrape_adventure(activity, state) ⇒ Object
Instance Method Details
#activity_url_creator(activity) ⇒ Object
6 7 8 |
# File 'lib/adventures/scraper.rb', line 6 def activity_url_creator(activity) activity.gsub(' ', '-') end |
#gather_adventures(activity, state) ⇒ Object
14 15 16 17 18 |
# File 'lib/adventures/scraper.rb', line 14 def gather_adventures(activity, state) scrape_adventure(activity, state).each do |a| Adventures::Adventure.new_from_scrape(a) end end |
#get_page(activity, state) ⇒ Object
2 3 4 |
# File 'lib/adventures/scraper.rb', line 2 def get_page(activity, state) doc = Nokogiri::HTML(open("https://www.theoutbound.com/#{state}/#{activity_url_creator(activity)}")) end |
#scrape_adventure(activity, state) ⇒ Object
10 11 12 |
# File 'lib/adventures/scraper.rb', line 10 def scrape_adventure(activity, state) self.get_page(activity, state).css("div.adventure-card--image") end |