Commit f5d71986 by Ngo Trung Hung

fix crawler

parent 81cfe475
......@@ -687,7 +687,6 @@ $main-color: #221f20;
.box_info_salary {
font-size: 13px;
color: #008563;
font-weight: 600;
transform: translateY(-2px);
}
.box_btn_favotite {
......@@ -818,7 +817,7 @@ $main-color: #221f20;
}
.box_text_five_jobs.box_padding_city {
background-color: #da6d2e;
background-image: linear-gradient(to right, #86cb49, #169b74, #86cb49);
color: white;
font-weight: 600;
margin-bottom: 0px !important;
......@@ -849,12 +848,13 @@ $main-color: #221f20;
cursor: pointer;
color: white;
text-align: center;
font-size: 18px;
font-size: 17px;
font-weight: bold;
}
.ct_jobs_count {
cursor: pointer;
font-size: 16px;
text-align: center;
color: #999;
}
......
......@@ -6,7 +6,7 @@ class City < ApplicationRecord
hash = {}
data_cities = City.all
data_cities.each do |val|
hash[val.id] = val.jobs.count
hash[val.name] = val.jobs.count
end
hash.sort_by { |k,v| v }.reverse
end
......
<div class="box_info_city">
<div class="ct_name">
<% data = City.find(k) %>
<%= link_to data.name, '#' ,class: 'link_ct'%>
<%= link_to name_city, '#' ,class: 'link_ct'%>
</div>
<div class="ct_jobs_count">
<%= link_to "#{v} công việc", '#' ,class: 'link_ct'%>
<%= link_to "#{jobs_count} công việc", '#' ,class: 'link_ct'%>
</div>
</div>
\ No newline at end of file
......@@ -6,11 +6,9 @@
<% @five_jobs.each do |val| %>
<div class="box_jobs">
<div class="col-sm-12 d-block d-sm-none">
<button type="submit" class="btn_favorite_outline xs">
<i class="far fa-heart"></i>
</button>
</div>
<div class="row">
<div class="col-sm-10 col-md-9 col-lg-10">
......@@ -31,7 +29,7 @@
<%= dt.join('').chomp('| ')%>
</h5>
</div>
<h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i> Lương: <%= val.salary %></h5>
<h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i>&nbsp; Lương: <%= val.salary %></h5>
<div class="coc">
<h5 class="box_info_des"><%= strip_tags(val.description) %></h5>
</div>
......
......@@ -6,7 +6,7 @@
<div class="row no-gutters">
<% @top_city.each do |k,v| %>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<%= render 'shared/block_cities_hot',k: k, v: v %>
<%= render 'shared/block_cities_hot',name_city: k, jobs_count: v %>
</div>
<% end %>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
......
......@@ -12,7 +12,7 @@ class Clawler
list_cities.each do |x|
data_list_cities << x.gsub(/(^<[\w\D]*>)/, '').gsub(/\n/,'').rstrip
end
puts "Save data to database... \n"
puts "Save data to database... \n------------------------"
data_list_cities.length.times do |i|
area = i > 69 ? 0 : 1
name = (data_list_cities[i].to_s)
......@@ -29,7 +29,7 @@ class Clawler
list_industries.each do |x|
data_list_industries << x.gsub(/(^<[\w\D]*>)/, '').gsub(/\n/,'').strip
end
puts "Save data to database... \n"
puts "Save data to database... \n------------------------"
data_list_industries.length.times do |i|
name = data_list_industries[i].to_s
if name.include?('&amp;')
......@@ -39,23 +39,27 @@ class Clawler
end
end
# FILL DATA COMPANIES
def self.make_companies
Company.create!(name: "Bảo mật",
address: "Vui lòng xem trong mô tả công việc",
short_description: "Vui lòng xem trong mô tả công việc")
# Company.create!(name: "Bảo mật",
# address: "Vui lòng xem trong mô tả công việc",
# short_description: "Vui lòng xem trong mô tả công việc")
Company.find_or_create_by(name: 'Bảo mật', address: 'Vui lòng xem trong mô tả công việc') do |company|
company.name = 'Bảo mật'
company.address = 'Vui lòng xem trong mô tả công việc'
company.short_description = 'Vui lòng xem trong mô tả công việc'
end
@data = Interface_web.craw_data_companies()
puts 'Save info companies to database . . .'
i = 0
@data[:name].each do |n|
if Company.find_by(name: n).blank?
address = @data[:address][i]
short_description = @data[:description][i]
Company.create!(name: n,
@data[:name].each_with_index do |name, index|
if Company.find_by(name: name).blank?
address = @data[:address][index]
short_description = @data[:description][index]
Company.create!(name: name,
address: address,
short_description: short_description)
end
i += 1
end
end
# FILL DATA JOBS
......
require 'src/crawler'
namespace :db do
task populate: :environment do
# Clawler.make_industries
# Clawler.make_cities
Clawler.make_industries
Clawler.make_cities
Clawler.make_companies
# Clawler.make_jobs
Clawler.make_jobs
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