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.57 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.56 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.55 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.54 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.53 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.52 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.51 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.50 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.49 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.48 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.47 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.46 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.45 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.44 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.43 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.42 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.41 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.40 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.39 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.38 lib/wco/scrape_wsj_capy.rb