5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/NBA_news/scraper.rb', line 5
def self.scrape
doc = Nokogiri::HTML(open(MAIN_SITE + "/us/nba/news"))
array_of_stories = doc.css("div.media-body")
array_of_stories.each do |info|
story = Story.new
story.title = info.css("h3.media-heading a").text
story.author = info.css("span.author a").text
story.url = info.css("a")[1]["href"]
end
def self.scrape_content(object)
doc = Nokogiri::HTML(open(MAIN_SITE + object))
x = doc.css("div.entry-content p").text.split(/[\\]/)
x.each {|w| puts "#{w} "}
end
end
|