Sha256: 5ad21e5f26122f5933270ff319e1f0ba143882d980061cfd7e3470a00f2ae5d5

Contents?: true

Size: 926 Bytes

Versions: 140

Compression:

Stored size: 926 Bytes

Contents

# require 'capybara/rspec'
# require 'byebug'
require 'capybara/rails'

Capybara.register_driver :selenium_chrome do |app|
  # options = Selenium::WebDriver::Chrome::Options.new
  # options.add_argument '--remote-debugging-port=4444'
  # Capybara::Selenium::Driver.new(app,
  #   browser: :chrome,
  #   options: options )

  Capybara::Selenium::Driver.new app, browser: :chrome
end

Capybara.default_driver = :selenium_chrome
Capybara.default_max_wait_time = 100 # seconds
Capybara.server = :webrick

class Wco::ScrapeTest
  include Capybara::DSL

  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

end

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
wco_models-3.1.0.99 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.98 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.97 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.96 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.95 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.94 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.93 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.92 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.91 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.90 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.89 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.88 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.87 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.86 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.85 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.83 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.82 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.81 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.80 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.79 lib/wco/scrape_wsj_capy.rb