Commit 8328deb3 by Mai Hoang Thai Ha

fixed review part 3

parent cdd2eeb9
...@@ -29,23 +29,24 @@ namespace :crawler do ...@@ -29,23 +29,24 @@ namespace :crawler do
update_at, job_type, salary, experience, level, expiration_date = '' update_at, job_type, salary, experience, level, expiration_date = ''
industries = [] industries = []
detail_box_items.each do |info_item| detail_box_items.each do |info_item|
info = info_item.text key = info_item.css('strong').text.strip
default_value = info_item.css('p').text.squish
# case/when # case/when
case case key
when info.include?(key = 'Ngày cập nhật') when 'Ngày cập nhật'
update_at = info.squish.remove(key).strip.to_time update_at = default_value.to_time
when info.include?(key = 'Ngành nghề') when 'Ngành nghề'
industries = info.squish.remove(key).strip.split(' , ') industries = default_value.split(' , ')
when info.include?(key = 'Hình thức') when 'Hình thức'
job_type = info.squish.remove(key).strip job_type = default_value
when info.include?(key = 'Lương') when 'Lương'
salary = info.squish.remove(key).strip salary = default_value
when info.include?(key = 'Kinh nghiệm') when 'Kinh nghiệm'
experience = info.squish.remove(key).strip experience = default_value.squish
when info.include?(key = 'Cấp bậc') when 'Cấp bậc'
level = info.squish.remove(key).strip level = default_value
when info.include?(key = 'Hết hạn nộp') when 'Hết hạn nộp'
expiration_date = info.squish.remove(key).strip.to_time expiration_date = default_value.to_time
end end
end end
# benefits, description, requirement, other_info # benefits, description, requirement, other_info
...@@ -56,13 +57,13 @@ namespace :crawler do ...@@ -56,13 +57,13 @@ namespace :crawler do
detail_content = detail_row.css(':not(h3.detail-title)') detail_content = detail_row.css(':not(h3.detail-title)')
case detail_title case detail_title
when 'Phúc lợi' when 'Phúc lợi'
benefits = get_detail_text(detail_content) benefits = detail_row.css('ul.welfare-list li').map(&:text).map(&:squish).join('---')
when 'Mô tả Công việc' when 'Mô tả Công việc'
description = get_detail_text(detail_content) description = detail_content.inner_html
when 'Yêu Cầu Công Việc' when 'Yêu Cầu Công Việc'
requirement = get_detail_text(detail_content) requirement = detail_content.inner_html
when 'Thông tin khác' when 'Thông tin khác'
other_info = get_detail_text(detail_content) other_info = detail_row.css('.content_fck ul li').map(&:text).map(&:squish).join('---')
end end
end end
# Company # Company
...@@ -124,8 +125,4 @@ namespace :crawler do ...@@ -124,8 +125,4 @@ namespace :crawler do
) )
end end
end end
def get_detail_text(arr)
arr.map(&:text).map(&:squish)[1..-1].reject(&:blank?).join('---')
end
end end
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