Class: SharksAhead::SharkLiving

Inherits:
Object
  • Object
show all
Defined in:
lib/sharks_ahead/shark-living.rb

Class Method Summary collapse

Class Method Details

.get_living_sharksObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sharks_ahead/shark-living.rb', line 3

def self.get_living_sharks
  living_sharks = []
  url = [
    'http://marinelife.about.com/od/vertebrates/p/baskingshark.htm',
    'http://marinelife.about.com/od/Sharks/p/Blue-Shark.htm',
    'http://marinelife.about.com/od/fish/p/Greatwhiteshark.htm',
    'http://marinelife.about.com/od/Sharks/p/Hammerhead-Sharks.htm',
    'http://marinelife.about.com/od/Shark-Profiles/fl/Megamouth-Shark.htm',
    'http://marinelife.about.com/od/Sharks/p/Nurse-Shark-Ginlymostoma-Cirratum.htm',
    'http://marinelife.about.com/od/Sharks/p/Tiger-Shark-Galeocerdo-Cuvier.htm',
    'http://marinelife.about.com/od/fish/p/whaleshark.htm',
    ]
  url.each do |u|
    doc = Nokogiri::HTML(open(u))
    name = doc.search('h1').text
    description = doc.search('article.content.widget.widget-alt.expert-content.expert-content-text p').text
    living_sharks << {name: name, description: description}
  end
  living_sharks
end