3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# 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/vertebrates/p/shortfinmako.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
|