fix crawler

parent e080cf4f
Pipeline #1362 failed with stages
in 0 seconds
class ChangeJobs < ActiveRecord::Migration[6.1] class ChangeJobs < ActiveRecord::Migration[6.1]
def up def up
change_column :jobs, :experience, :string change_column :jobs, :experience, :string
change_column :jobs, :salary, :string
rename_column :jobs, :type, :job_type
end end
def down def down
change_column :jobs, :experience, :integer change_column :jobs, :experience, :integer
change_column :jobs, :salary, :integer
end end
end end
require 'open-uri' require 'open-uri'
require 'logger'
namespace :crawler do namespace :crawler do
desc 'Crawl Jobs and Companies' desc 'Crawl Jobs and Companies'
...@@ -47,7 +46,7 @@ namespace :crawler do ...@@ -47,7 +46,7 @@ namespace :crawler do
slug_job = CGI.escape(detail_jobs.css('a.job_link').attribute('href').text slug_job = CGI.escape(detail_jobs.css('a.job_link').attribute('href').text
.gsub('https://careerbuilder.vn/vi/tim-viec-lam/', '').strip) .gsub('https://careerbuilder.vn/vi/tim-viec-lam/', '').strip)
job_detail_page = "https://careerbuilder.vn/vi/tim-viec-lam/#{slug_job}" job_detail_page = "https://careerbuilder.vn/vi/tim-viec-lam/#{slug_job}"
parse_job_detail_page = Nokogiri::HTML(URI.open(job_detail_page).read) parse_job_detail_page = Nokogiri::HTML(URI.open(job_detail_page))
detail_job = parse_job_detail_page.css('div.container') detail_job = parse_job_detail_page.css('div.container')
title = detail_job.css('div.job-desc h1.title') title = detail_job.css('div.job-desc h1.title')
next if title.nil? next if title.nil?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment