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.187 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.184 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.183 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.182 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.181 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.180 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.178 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.177 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.176 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.175 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.174 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.173 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.172 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.171 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.170 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.169 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.168 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.167 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.166 lib/wco/scrape_wsj_capy.rb
wco_models-3.1.0.165 lib/wco/scrape_wsj_capy.rb