Commit 8ab617be by Mai Hoang Thai Ha

created and import job, company, industry, city to DB

parent 2b3e5d23
=> #<Job:0x00007f490830e500
=> #<Job:0x00007f490830e500
id: 1,
title: "[Hà Nội] - CHUYÊN GIA TƯ VẤN BẢO HIỂM KHÁCH HÀNG ƯU TIÊN - Kênh Liên Kết Ngân Hàng Techcombank (Bancassurance)",
type: nil,
salary: "18 Tr - 28 Tr VND",
experience: "1 - 2 Năm",
position: "Nhân viên",
expiration_date: Sun, 15 Aug 2021 00:00:00.000000000 UTC +00:00,
description:
"MÔ TẢ CÔNG VIỆC: Bancassurance là kênh hợp tác giữa tập đoàn bảo hiểm nhân thọ Manulife và ngân hàng Techcombank.Chuyên Gia Bảo Hiểm (TIS) làm việc tại ngân hàng Techcombank, phụ trách các công việc sau: Khai thác nguồn khách hàng tiềm năng và chất lượng từ ngân hàng, Techcombank tăng trung bình 150.000 khách hàng mới/tháng nhờ hệ thống Digital Banking & Zero free. TIS nhận thông tin giới thiệu khách hàng tiềm năng từ các lực lượng Quan hệ khách hàng ưu tiên (PRM) để tư vấn các sản phẩm bảo hiểm phù hợp với nhu cầu tài chính của từng khách hàng. Được refer nguồn khách hàng tiềm năng từ toàn bộ các lực lượng bán: GDV, CSO, RBO, SRBO, PRM để tư vấn sản phảm bảo hiểm đầu tư Hỗ trợ khách hàng hoàn thiện bộ hồ sơ bảo hiểm theo đúng quy định của Manulife và Techcombank Là đầu mối chính chăm sóc, hỗ trợ khi khách hàng cần được giải đáp thắc mắc về các vấn đề liên quan đến bảo hiểm, xây dựng mối quan hệ tốt đẹp với Khách hàng ĐỊA ĐIỂM & THỜI GIAN LÀM VIỆC Địa điểm: Siêu chi nhánh/chi nhánh lớn của Ngân hàng trên toàn quốc Thời gian làm việc: 8h30 – 17h30, thứ 2 – thứ 6, & sáng thứ 7 QUYỀN LỢI: Lương cơ bản: 18.000.000 – 28.000.000/tháng, được xét tăng lương hàng năm theo kết quả xếp loại. Thu nhập TIS luôn cạnh tranh so với thị trường. Được ký Hợp đồng lao động, là nhân viên chính thức của Techcombank (Hưởng lương tháng 13, thưởng hiệu quả công việc và các quyền lợi khác như: Chương trình vay ưu đãi, Bảo hiểm sức khỏe Aeon, chế độ 15 ngày phép/năm, khám sức khỏe định kì ...) Thưởng kinh doanh hấp dẫn theo quý căn cứ trên hiệu quả công việc, Mức thưởng từ 24-96 triệu đồng/tháng. Được hướng dẫn, đào tạo thường xuyên bởi Giám đốc bảo hiểm vùng, Giám đốc kinh doanh vùng (Manulife), Giám đốc chi nhánh…. Được hỗ trợ tối đa bởi các TIA (Admin) trước/trong/sau quá trình bán hàng, giúp Chuyên Gia Bảo Hiểm tập trung vào tư vấn sản phẩm cho khách hàng. Cơ hội thăng tiến lên vị trí Quản Lí Quan Hệ Khách Hàng Ưu Tiên/ Giám Đốc Dịch Vụ/ Giám Đốc Chi Nhánh hoặc các vị trí đào tạo bán/ phát triển sản phẩm bảo hiểm tại Hội sở. Được làm việc tại Techcombank, là nơi làm việc chuyên nghiệp với: Mức tăng trưởng ấn tượng: Ngân hàng TMCP số 1 tại Việt Nam về lợi nhuận trong 5 năm liên tiếp Môi trường làm việc gắn kết với các hoạt động teambuilding hàng năm, sinh nhật, các câu lạc bộ ngoài giờ, Year-end Party…",
benefit:
"[\"Chế độ bảo hiểm\", \"Du Lịch\", \"Phụ cấp\", \"Du lịch nước ngoài\", \"Đồng phục\", \"Chế độ thưởng\", \"Chăm sóc sức khỏe\", \"Đào tạo\", \"Tăng lương\", \"Công tác phí\", \"Phụ cấp thâm niên\", \"Nghỉ phép năm\", \"CLB thể thao\"]",
requirement:
"KINH NGHIỆM/KỸ NĂNG CHI TIẾT Trình độ học vấn: Tốt nghiệp Cao đẳng/Đại học (Ưu tiên chuyên ngành Bảo hiểm, ngân hàng, Kinh tế, tài chính, quản trị kinh doanh.......) Có tối thiểu 1 năm kinh nghiệm tư vấn trong lĩnh vực tư vấn Bảo hiểm nhân thọ và 1 năm kinh nghiệm sales Tài chính/Ngân hàng. Đã có kinh nghiệm trong mảng Ngân hàng/Dịch vụ Khách hàng ưu tiên là lợi thế. Am hiểu về các sản phẩm bảo hiểm và về khách hàng cá nhân hoặc khách hàng doanh nghiệp Kỹ năng: Kĩ năng tư vấn, thuyết phục và khai thác nhu cầu của khách hàng Kỹ năng phát triển mối quan hệ với khách hàng Có tinh thần học hỏi, quan tâm gắn bó và phát triển lâu dài với Techcombank",
other_info: "[\"Bằng cấp: Cao đẳng\", \"Độ tuổi: Không giới hạn tuổi\"]",
company_id: 1,
created_at: Thu, 15 Jul 2021 05:51:56.429636000 UTC +00:00,
updated_at: Thu, 15 Jul 2021 05:51:56.429636000 UTC +00:00>
class User < ApplicationRecord class User < ApplicationRecord
has_many :apply_jobs has_many :apply_jobs, dependent: :destroy
has_many :favorite_jobs has_many :favorite_jobs, dependent: :destroy
has_many :history_jobs has_many :history_jobs, dependent: :destroy
has_one_attached :cv has_one_attached :cv
end end
...@@ -2,8 +2,6 @@ class CreateCompanies < ActiveRecord::Migration[6.1] ...@@ -2,8 +2,6 @@ class CreateCompanies < ActiveRecord::Migration[6.1]
def change def change
create_table :companies do |t| create_table :companies do |t|
t.string :name t.string :name
t.text :description
t.string :address
t.timestamps t.timestamps
end end
......
...@@ -2,7 +2,7 @@ class CreateJobs < ActiveRecord::Migration[6.1] ...@@ -2,7 +2,7 @@ class CreateJobs < ActiveRecord::Migration[6.1]
def change def change
create_table :jobs do |t| create_table :jobs do |t|
t.string :title t.string :title
t.string :type t.string :job_type
t.string :salary t.string :salary
t.string :experience t.string :experience
t.string :position t.string :position
......
class IndustriesJobs < ActiveRecord::Migration[6.1]
def change
end
end
class CitiesJobs < ActiveRecord::Migration[6.1]
def change
end
end
class CreateIndustriesJobs < ActiveRecord::Migration[6.1]
def change
create_table :industries_jobs do |t|
t.references :job, null: false, foreign_key: true
t.references :industry, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateCitiesJobs < ActiveRecord::Migration[6.1]
def change
create_table :cities_jobs do |t|
t.references :job, null: false, foreign_key: true
t.references :city, null: false, foreign_key: true
t.timestamps
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_07_06_093559) do ActiveRecord::Schema.define(version: 2021_07_15_053121) do
create_table "active_storage_attachments", force: :cascade do |t| create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
...@@ -56,10 +56,17 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do ...@@ -56,10 +56,17 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "cities_jobs", force: :cascade do |t|
t.integer "job_id", null: false
t.integer "city_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["city_id"], name: "index_cities_jobs_on_city_id"
t.index ["job_id"], name: "index_cities_jobs_on_job_id"
end
create_table "companies", force: :cascade do |t| create_table "companies", force: :cascade do |t|
t.string "name" t.string "name"
t.text "description"
t.string "address"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
...@@ -88,9 +95,18 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do ...@@ -88,9 +95,18 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "industries_jobs", force: :cascade do |t|
t.integer "job_id", null: false
t.integer "industry_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["industry_id"], name: "index_industries_jobs_on_industry_id"
t.index ["job_id"], name: "index_industries_jobs_on_job_id"
end
create_table "jobs", force: :cascade do |t| create_table "jobs", force: :cascade do |t|
t.string "title" t.string "title"
t.string "type" t.string "job_type"
t.string "salary" t.string "salary"
t.string "experience" t.string "experience"
t.string "position" t.string "position"
...@@ -126,9 +142,13 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do ...@@ -126,9 +142,13 @@ ActiveRecord::Schema.define(version: 2021_07_06_093559) do
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "apply_jobs", "jobs" add_foreign_key "apply_jobs", "jobs"
add_foreign_key "apply_jobs", "users" add_foreign_key "apply_jobs", "users"
add_foreign_key "cities_jobs", "cities"
add_foreign_key "cities_jobs", "jobs"
add_foreign_key "favorite_jobs", "jobs" add_foreign_key "favorite_jobs", "jobs"
add_foreign_key "favorite_jobs", "users" add_foreign_key "favorite_jobs", "users"
add_foreign_key "history_jobs", "jobs" add_foreign_key "history_jobs", "jobs"
add_foreign_key "history_jobs", "users" add_foreign_key "history_jobs", "users"
add_foreign_key "industries_jobs", "industries"
add_foreign_key "industries_jobs", "jobs"
add_foreign_key "jobs", "companies" add_foreign_key "jobs", "companies"
end end
...@@ -14,7 +14,7 @@ namespace :crawler do ...@@ -14,7 +14,7 @@ namespace :crawler do
task a.to_sym { ; } task a.to_sym { ; }
case a case a
when 'TEST' when 'TEST'
total_pages = 5 total_pages = 1
when 'ALL' when 'ALL'
first_page = Nokogiri::HTML(HTTParty.get('https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-vi.html').body) first_page = Nokogiri::HTML(HTTParty.get('https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-vi.html').body)
jobs_per_page = first_page.css('div.job-item').count jobs_per_page = first_page.css('div.job-item').count
...@@ -31,7 +31,6 @@ namespace :crawler do ...@@ -31,7 +31,6 @@ namespace :crawler do
(1..total_pages).each do |page| (1..total_pages).each do |page|
parsed_page = Nokogiri::HTML(HTTParty.get("https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-#{page}-vi.html").body) parsed_page = Nokogiri::HTML(HTTParty.get("https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-#{page}-vi.html").body)
jobs_item = parsed_page.css('div.job-item .job_link') jobs_item = parsed_page.css('div.job-item .job_link')
puts page
jobs_item.each do |item| jobs_item.each do |item|
job_page = Nokogiri::HTML(HTTParty.get('https://careerbuilder.vn/vi/tim-viec-lam/' + job_page = Nokogiri::HTML(HTTParty.get('https://careerbuilder.vn/vi/tim-viec-lam/' +
CGI.escape(item.attribute('href').text.remove('https://careerbuilder.vn/vi/tim-viec-lam/'))).body) CGI.escape(item.attribute('href').text.remove('https://careerbuilder.vn/vi/tim-viec-lam/'))).body)
...@@ -39,20 +38,26 @@ namespace :crawler do ...@@ -39,20 +38,26 @@ namespace :crawler do
# title - company # title - company
title = job_page.css('div.job-desc h1.title').text title = job_page.css('div.job-desc h1.title').text
company = job_page.css('div.job-desc a.job-company-name').text company = job_page.css('div.job-desc a.job-company-name').text
Company.create!(name: company)
# info box # info box
info_box_item = job_detail.css('.detail-box ul li') info_box_item = job_detail.css('.detail-box ul li')
# city, update_at, industry, type, salary, experience, level, expiration_date # city, update_at, industry, type, salary, experience, level, expiration_date
update_at, industry, type, salary, experience, level, expiration_date = '' job_industries = []
city = job_detail.css('.detail-box .map a').text update_at, job_type, salary, experience, level, expiration_date = ''
job_cities = []
job_detail.css('.detail-box .map a').each do |part|
city = part.text
job_cities << city
end
info_box_item.each do |info_item| info_box_item.each do |info_item|
info = info_item.text info = info_item.text
if info.include?(key = 'Ngày cập nhật') if info.include?(key = 'Ngày cập nhật')
update_at = info.squish.remove(key).strip update_at = info.squish.remove(key).strip
elsif info.include?(key = 'Ngành nghề') elsif info.include?(key = 'Ngành nghề')
industry = info.squish.remove(key).strip job_industries = info.squish.remove(key).strip.split(' , ')
elsif info.include?(key = 'Hình thức') elsif info.include?(key = 'Hình thức')
type = info.squish.remove(key).strip job_type = info.squish.remove(key).strip
elsif info.include?(key = 'Lương') elsif info.include?(key = 'Lương')
salary = info.squish.remove(key).strip salary = info.squish.remove(key).strip
elsif info.include?(key = 'Kinh nghiệm') elsif info.include?(key = 'Kinh nghiệm')
...@@ -90,24 +95,28 @@ namespace :crawler do ...@@ -90,24 +95,28 @@ namespace :crawler do
info = part.text.squish.strip info = part.text.squish.strip
other_info_list << info other_info_list << info
end end
job = {
job = Job.find_or_create_by(
title: title, title: title,
company: company, job_type: job_type,
city: city,
update_at: update_at,
industry: industry,
type: type,
salary: salary, salary: salary,
experences: experience, position: level,
level: level, experience: experience,
# position: position,
expiration_date: expiration_date, expiration_date: expiration_date,
benefit: benefit_list, benefit: benefit_list.each { |benefit| },
description: description, description: description,
requirement: requirement, requirement: requirement,
other_info: other_info_list other_info: other_info_list.each { |info| }
} )
puts job Company.find_or_initialize_by(name: company).jobs << job
job_industries.each do |industry|
industry_id = Industry.find_or_create_by(name: industry)
job.industries << industry_id
end
job_cities.each do |city|
city_id = City.find_or_create_by(name: city)
job.cities << city_id
end
end end
end end
end end
......
This diff is collapsed. Click to expand it.
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