Class: Sites::RemoteOk
Constant Summary collapse
- HOST =
'https://remoteok.io'.freeze
- PATH =
'/remote-dev-jobs'.freeze
- JOB_ITEM_SELECTOR =
'tr.job'.freeze
- STORE_DIR =
'data/remote_ok'.freeze
Instance Attribute Summary
Attributes inherited from Base
#doc, #jobs_count, #rows_count, #url
Instance Method Summary collapse
- #collect_jobs(limit: nil) ⇒ Object
-
#initialize ⇒ RemoteOk
constructor
A new instance of RemoteOk.
Constructor Details
#initialize ⇒ RemoteOk
Returns a new instance of RemoteOk.
11 12 13 |
# File 'lib/sites/remote_ok.rb', line 11 def initialize super end |
Instance Method Details
#collect_jobs(limit: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sites/remote_ok.rb', line 15 def collect_jobs(limit: nil) puts "[Info] Getting the data from #{url}" FileUtils.mkdir_p STORE_DIR CSV.open(filepath, 'w') do |csv| doc.css(JOB_ITEM_SELECTOR).each do |link| return if limit == @rows_count job_url = "#{HOST}#{link["data-url"]}" puts "[Info] Parsing #{job_url}..." csv << get_row(job_url) @rows_count += 1 end end puts "[Done] Collected #{@rows_count} job offers from #{url}. Data stored in: #{filepath}." end |