Sha256: 09758364b8fed7d3238018e179a9a289d8f9cf9a7e2cb0125ef931253fbff073

Contents?: true

Size: 1.51 KB

Versions: 7

Compression:

Stored size: 1.51 KB

Contents

require_relative 'base'

module Sites
  class WeWorkRemotely < Base

    HOST = 'https://weworkremotely.com'.freeze
    PROGRAMMING = '/categories/remote-programming-jobs'.freeze
    DEVOPS     = '/categories/remote-devops-sysadmin-jobs'.freeze
    JOB_ITEM_SELECTOR = '.jobs-container li a'.freeze
    STORE_DIR = 'data/we_work_remotely'

    def initialize(args = {})
      super(args = {})
    end

    def collect_jobs
      puts "[Info] Getting the data from #{url} at #{@current_time}..."
      FileUtils.mkdir_p STORE_DIR

      CSV.open(filepath, 'w') do |csv|
        doc.css(JOB_ITEM_SELECTOR).each do |link|
          if link["href"].start_with?("/remote-jobs")
            job_url = "#{HOST}#{link["href"]}"
            puts "[Info] Processing #{job_url}..."
            job_page = Nokogiri::HTML(open_page(job_url))
            offer_text = job_page.css('.listing-container').to_s

            region = job_page.css('span.region').first
            location = job_page.css('span.location').first

            keywords = Support::OfferParser.get_keywords(offer_text)

            csv << [job_url, location, region, keywords]
          end
        end
      end

      puts "[Done] Collected #{@count} job offers from #{url}. Data stores in: #{filepath}."
    end

    private

    def get_count
      count = doc.css(JOB_ITEM_SELECTOR)
        .map { |link| link['href'] }
        .select { |href| href.start_with?('/remote-jobs') }
        .size
      puts "[Info] There is #{count} remote jobs available."
      count
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
remote_job_scraper-0.4.2 lib/sites/we_work_remotely.rb
remote_job_scraper-0.4.1 lib/sites/we_work_remotely.rb
remote_job_scraper-0.4.0 lib/sites/we_work_remotely.rb
remote_job_scraper-0.3.1 lib/sites/we_work_remotely.rb
remote_job_scraper-0.3.0 lib/sites/we_work_remotely.rb
remote_job_scraper-0.2.0 lib/sites/we_work_remotely.rb
remote_job_scraper-0.1.0 lib/sites/we_work_remotely.rb