Class: BestCity::Scraper
- Inherits:
-
Object
- Object
- BestCity::Scraper
- Defined in:
- lib/best_cities/scraper.rb
Instance Method Summary collapse
Instance Method Details
#get_page ⇒ Object
3 4 5 6 |
# File 'lib/best_cities/scraper.rb', line 3 def get_page Nokogiri::HTML(open("http://www.businessinsider.com/us-news-best-places-to-live-in-america-2016-3")) ##Nokogiri::HTML(open("http://www.metacritic.com/browse/games/score/metascore/year/xboxone/filtered")) end |
#make_games ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/best_cities/scraper.rb', line 12 def make_games scrape_game_index.each do |c| city= c.css("h3.slide-title").text pop= c.css("p:first").text.split(":")[1] sal= c.css("p:nth-of-type(2)").text.split("$")[1] qual= c.css("p:nth-of-type(3)").text.split(":")[1] value= c.css("p:nth-of-type(4)").text.split(":")[1] desc= c.css("p:nth-of-type(5)").text BestCity::City.new( city,pop,sal,qual,value,desc ) end end |
#scrape_game_index ⇒ Object
8 9 10 |
# File 'lib/best_cities/scraper.rb', line 8 def scrape_game_index self.get_page.css("div.slide-module") end |