Class: Wco::ScrapeTest

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL
Defined in:
lib/wco/scrape_wsj_capy.rb

Instance Method Summary collapse

Constructor Details

#initializeScrapeTest

Returns a new instance of ScrapeTest.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/wco/scrape_wsj_capy.rb', line 23

def initialize

  visit 'https://www.wsj.com/'

  # all('h6').each_with_index do |h6, idx|
  (1...2).each do |idx|
    headline = find(:xpath, "(//h3)[#{idx}]").text
    # puts "+++ Title: #{title}"

    Wco::Headline.create!({
      name: headline,
      site: wsj,
      date: Time.now.to_date,
    })
    print '.'
  end

  # byebug
end