Class: Sites::WeWorkRemotely

Inherits:
Base
  • Object
show all
Defined in:
lib/sites/we_work_remotely.rb

Constant Summary collapse

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'

Instance Attribute Summary

Attributes inherited from Base

#doc, #job_type, #url

Instance Method Summary collapse

Methods inherited from Base

#open_page

Constructor Details

#initialize(args = {}) ⇒ WeWorkRemotely

Returns a new instance of WeWorkRemotely.



12
13
14
# File 'lib/sites/we_work_remotely.rb', line 12

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

Instance Method Details

#collect_jobsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sites/we_work_remotely.rb', line 16

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