Sha256: 059ddb7c4e15f59274c86e42d635bf59c20fbab06803599b0627a23ce03b463f

Contents?: true

Size: 636 Bytes

Versions: 24

Compression:

Stored size: 636 Bytes

Contents

require 'httparty'

class Wco::ScrapeWsj

  def initialize site: nil, max_count: 2
    site ||= Wco::Site.find_by slug: 'wsj'

    # out = HTTParty.get( site.origin ).response.body
    # out = `curl #{site.origin}`
    out = Nokogiri::HTML(out)
    out.css('h3').each_with_index do |headline, idx|
      if idx < max_count
        puts! headline.text, 'headline'
        h = Wco::Headline.create({
          date: Time.now.to_date,
          site: site,
          name: headline.text,
        })
        if h.persisted?
          print '.'
        else
          puts! h.errors.full_messages
        end
      end
    end

  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
wco_models-3.1.0.187 lib/wco/scrape_wsj.rb
wco_models-3.1.0.184 lib/wco/scrape_wsj.rb
wco_models-3.1.0.183 lib/wco/scrape_wsj.rb
wco_models-3.1.0.182 lib/wco/scrape_wsj.rb
wco_models-3.1.0.181 lib/wco/scrape_wsj.rb
wco_models-3.1.0.180 lib/wco/scrape_wsj.rb
wco_models-3.1.0.178 lib/wco/scrape_wsj.rb
wco_models-3.1.0.177 lib/wco/scrape_wsj.rb
wco_models-3.1.0.176 lib/wco/scrape_wsj.rb
wco_models-3.1.0.175 lib/wco/scrape_wsj.rb
wco_models-3.1.0.174 lib/wco/scrape_wsj.rb
wco_models-3.1.0.173 lib/wco/scrape_wsj.rb
wco_models-3.1.0.172 lib/wco/scrape_wsj.rb
wco_models-3.1.0.171 lib/wco/scrape_wsj.rb
wco_models-3.1.0.170 lib/wco/scrape_wsj.rb
wco_models-3.1.0.169 lib/wco/scrape_wsj.rb
wco_models-3.1.0.168 lib/wco/scrape_wsj.rb
wco_models-3.1.0.167 lib/wco/scrape_wsj.rb
wco_models-3.1.0.166 lib/wco/scrape_wsj.rb
wco_models-3.1.0.165 lib/wco/scrape_wsj.rb