13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bucs_roster/scraper.rb', line 13
def self.scrape_player(index)
player = Player.all[index]
html = open(player.player_URL)
doc = Nokogiri::HTML(html)
player.experience = doc.search("div.nfl-t-person-tile__details p")[0].text.gsub("Experience: ","")
player.height = doc.search("div.nfl-t-person-tile__details p")[1].text.gsub("Height: ","")
player.age = doc.search("div.nfl-t-person-tile__details p")[2].text.gsub("Age: ","")
player.weight = doc.search("div.nfl-t-person-tile__details p")[3].text.gsub("Weight: ","")
player.college = doc.search("div.nfl-t-person-tile__details p")[4].text.gsub("College: ","")
player.position = doc.search("h3.d3-o-media-object__primary-subtitle").text.strip
player.jersey_number = doc.search("h3.d3-o-media-object__secondary-subtitle").text.strip
player.bio = ""
bio = doc.search("div.nfl-c-body-part.nfl-c-body-part--text p")[2..-1]
if bio != nil
bio.each do |bio_fact|
player.bio = player.bio + bio_fact.text + "\n\n"
end
else
player.bio = "No player bio available."
end
end
|