Commit 8328deb3 by Mai Hoang Thai Ha

fixed review part 3

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