Class: Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/NBA_news/scraper.rb

Constant Summary collapse

MAIN_SITE =
"http://www.sportingnews.com"

Class Method Summary collapse

Class Method Details

.scrapeObject



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

.scrape_content(object) ⇒ Object



16
17
18
19
20
# File 'lib/NBA_news/scraper.rb', line 16

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