Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
Venjob_HungNT
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ngô Trung Hưng
Venjob_HungNT
Commits
36b7290d
Commit
36b7290d
authored
Jul 20, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
92724316
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
71 additions
and
37 deletions
+71
-37
app/assets/stylesheets/custom.scss
+23
-7
app/controllers/home_controller.rb
+1
-3
app/models/company.rb
+0
-7
app/models/job.rb
+1
-0
app/views/home/index.html.erb
+1
-0
app/views/shared/_box_five_job.html.erb
+13
-4
config/database.yml
+1
-1
db/migrate/20200720035021_add_column_newdata_to_table_jobs.rb
+5
-0
db/schema.rb
+2
-1
lib/src/crawler.rb
+14
-9
lib/src/interface_web.rb
+9
-4
lib/tasks/crawler.rake
+1
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
36b7290d
...
...
@@ -236,11 +236,11 @@ $main-color: #221f20;
}
.slogan_text
{
text-align
:
center
;
font-family
:
sans-serif
;
font-family
:
'Raleway'
,
sans-serif
;
font-size
:
35px
;
color
:
#eaeaea
;
transform
:
scale
(
1
.35
);
font-weight
:
6
00
;
font-weight
:
7
00
;
margin
:
0
;
padding
:
0
;
}
...
...
@@ -637,7 +637,7 @@ $main-color: #221f20;
height
:
18px
;
transform
:
translateY
(
-1px
);
}
.job_name
{
.job_name
{
font-size
:
16px
;
line-height
:
14px
;
font-weight
:
600
;
...
...
@@ -670,9 +670,11 @@ $main-color: #221f20;
-webkit-box-orient
:
vertical
;
}
.box_info_location
{
font-size
:
1
3
px
;
font-size
:
1
4
px
;
color
:
#666
;
margin-top
:
5px
;
margin-top
:
-4px
;
line-height
:
24px
;
}
.box_info_salary
{
font-size
:
13px
;
...
...
@@ -687,7 +689,17 @@ $main-color: #221f20;
// background-color: #d41323;
}
.coc
{
height
:
12
.5px
;
height
:
13px
;
width
:
100%
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
display
:
-
webkit-box
;
-webkit-line-clamp
:
1
;
-webkit-box-orient
:
vertical
;
margin-top
:
-3px
;
}
.loc
{
height
:
24px
;
width
:
100%
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
...
...
@@ -699,7 +711,7 @@ $main-color: #221f20;
.box_info_des
{
width
:
100%
;
font-size
:
12
.5px
;
line-height
:
1
2
.5
px
;
line-height
:
1
3
px
;
color
:
#888
;
margin
:
0
;
}
...
...
@@ -817,6 +829,10 @@ $main-color: #221f20;
background-color
:
white
;
}
.loc
{
margin-top
:
5px
;
width
:
90%
;
}
.btn_search_submit
{
height
:
30px
;
}
...
...
app/controllers/home_controller.rb
View file @
36b7290d
...
...
@@ -3,9 +3,7 @@ class HomeController < ApplicationController
def
index
@data_industries
=
Industry
.
sort_asc
.
all
@data_total_job
=
Job
.
all
.
count
@data_five_jobs
=
Company
.
get_5_last_jobs
()
@data_five_jobs
=
Job
.
order
(
created_at: :asc
).
where
(
newdata:
1
).
limit
(
5
)
@data_cities
=
City
.
all
end
end
app/models/company.rb
View file @
36b7290d
class
Company
<
ApplicationRecord
has_many
:jobs
def
self
.
get_5_last_jobs
data
=
Company
.
joins
(
:jobs
).
select
(
'companies.*, jobs.name as job_title,
jobs.created_at as job_created,
jobs.salary,
jobs.description'
).
where
(
'companies.id = jobs.company_id'
)
@data_five_jobs
=
data
.
order
(
job_created: :asc
).
limit
(
5
)
end
end
app/models/job.rb
View file @
36b7290d
...
...
@@ -12,4 +12,5 @@ class Job < ApplicationRecord
has_many
:histories
has_many
:favorites
end
app/views/home/index.html.erb
View file @
36b7290d
<%
provide
(
:title
,
'Trang chủ'
)
%>
<%=
render
'home/banner_and_search'
%>
<div
class=
"padding_index"
></div>
<div
class=
"box_text_five_jobs"
>
...
...
app/views/shared/_box_five_job.html.erb
View file @
36b7290d
...
...
@@ -2,6 +2,7 @@
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<%
i
=
0
%>
<%
@data_five_jobs
.
each
do
|
val
|
%>
<div
class=
"box_jobs"
>
<div
class=
"col-sm-12 d-block d-sm-none"
>
...
...
@@ -15,13 +16,21 @@
<div
class=
"col-sm-10 col-md-9 col-lg-10"
>
<div
class=
"box_info"
>
<div
class=
"lol"
>
<%=
link_to
"
#{
val
.
job_titl
e
}
"
,
"#"
,
class:
"job_name"
%>
<%=
link_to
"
#{
val
.
nam
e
}
"
,
"#"
,
class:
"job_name"
%>
<%=
image_tag
'trophy'
,
class:
"img_job_name"
%>
</div>
<div
class =
"cop"
>
<h5
class=
"box_info_copany_name"
><i
class=
"far fa-building"
></i>
<%=
val
.
name
%>
</h5>
<h5
class=
"box_info_copany_name"
><i
class=
"far fa-building"
></i>
<%=
val
.
company
.
name
%>
</h5>
</div>
<div
class=
"loc"
>
<h5
class=
"box_info_location"
><i
class=
"fas fa-map-marker-alt"
></i>
<%
@dt
=
[]
%>
<%
val
.
cities
.
each
do
|
x
|
%>
<%
@dt
<<
(
x
.
name
<<
' | '
)
%>
<%
end
%>
<%=
@dt
.
join
(
''
).
chomp
(
'| '
)
%>
</h5>
</div>
<h5
class=
"box_info_location"
><i
class=
"fas fa-map-marker-alt"
></i>
<%=
val
.
address
%>
</h5>
<h5
class=
"box_info_salary"
><i
class=
"fas fa-dollar-sign"
></i>
Lương:
<%=
val
.
salary
%>
</h5>
<div
class=
"coc"
>
<h5
class=
"box_info_des"
>
<%=
strip_tags
(
val
.
description
)
%>
</h5>
...
...
@@ -41,7 +50,7 @@
</div>
</div>
</div>
</div>
<%
end
%>
</div>
</div>
...
...
config/database.yml
View file @
36b7290d
...
...
@@ -14,7 +14,7 @@ default: &default
encoding
:
utf8
pool
:
<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username
:
root
password
:
'
1
2345678
'
password
:
'
1'
socket
:
/var/run/mysqld/mysqld.sock
...
...
db/migrate/20200720035021_add_column_newdata_to_table_jobs.rb
0 → 100644
View file @
36b7290d
class
AddColumnNewdataToTableJobs
<
ActiveRecord
::
Migration
[
5.2
]
def
change
add_column
:jobs
,
:newdata
,
:boolean
end
end
db/schema.rb
View file @
36b7290d
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2020_07_
15_090747
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_07_
20_035021
)
do
create_table
"applied_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
...
...
@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do
t
.
text
"description"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
boolean
"newdata"
end
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
...
...
lib/src/crawler.rb
View file @
36b7290d
...
...
@@ -44,22 +44,26 @@ class Clawler
# FILL DATA COMPANIES
def
self
.
make_companies
Company
.
create!
(
name:
"Company name"
,
address:
"Vui lòng
trong mô tả công việc"
,
short_description:
"Vui lòng
trong mô tả công việc"
)
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"
)
@data
=
Interface_web
.
craw_data_companies
()
i
=
@data
[
:name
].
length
i
.
times
do
|
n
|
name
=
@data
[
:name
][
n
]
address
=
@data
[
:address
][
n
]
short_description
=
@data
[
:description
][
n
]
Company
.
create!
(
name:
name
,
address:
address
,
short_description:
short_description
)
if
Company
.
find_by
(
"name = ?"
,
name
)
next
else
address
=
@data
[
:address
][
n
]
short_description
=
@data
[
:description
][
n
]
Company
.
create!
(
name:
name
,
address:
address
,
short_description:
short_description
)
end
end
end
# FILL DATA JOBS
def
self
.
make_jobs
Job
.
update_all
(
newdata:
0
)
@data_jobs
=
Interface_web
.
make_data
()
i
=
@data_jobs
[
:name
].
length
i
.
times
do
|
n
|
...
...
@@ -85,7 +89,8 @@ class Clawler
salary:
salary
,
create_date:
create_date
,
expiration_date:
expiration_date
,
description:
description
)
description:
description
,
newdata:
1
)
self
.
make_foreign_industries_table
(
@data_jobs
[
:industry_name
][
n
],
id_job
.
id
)
self
.
make_foreign_cities_table
(
@data_jobs
[
:city_name
][
n
],
id_job
.
id
)
end
...
...
lib/src/interface_web.rb
View file @
36b7290d
...
...
@@ -21,9 +21,9 @@ class Interface_web
data
<<
website_companies
<<
website_jobs
end
@crawl_link_for_companies_jobs
=
crawl_link_for_companies_jobs
(
7
)
@crawl_link_for_companies_jobs
=
crawl_link_for_companies_jobs
(
1
)
def
self
.
get_link_job_and_companies
@crawl_link_for_companies_jobs
||=
crawl_link_for_companies_jobs
(
7
)
@crawl_link_for_companies_jobs
||=
crawl_link_for_companies_jobs
(
1
)
end
def
self
.
base_link
(
url
)
...
...
@@ -254,7 +254,8 @@ class Interface_web
add_data
()
end
def
self
.
make_data
def
self
.
make_data
puts
'Please wait for crawl jobs data! . . .'
@data
=
{}
@name
=
[]
@company_name
=
[]
...
...
@@ -268,13 +269,17 @@ class Interface_web
@city_name
=
[]
link_crawl
=
get_link_job_and_companies
total_jobs
=
link_crawl
[
1
].
length
current_job
=
1
link_crawl
[
1
].
each
do
|
path
|
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
parse
(
URI
.
escape
(
"https://careerbuilder.vn/
#{
path
}
"
))))
if
page
.
search
(
".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p"
)[
0
]
!=
nil
crawl_data_jobs_interface_1
(
path
)
crawl_data_jobs_interface_1
(
path
)
elsif
page
.
search
(
".DetailJobNew ul li"
).
size
==
10
crawl_data_jobs_interface_5
(
path
)
end
puts
"Process:
#{
current_job
}
/
#{
total_jobs
}
"
current_job
+=
1
end
@data
end
...
...
lib/tasks/crawler.rake
View file @
36b7290d
...
...
@@ -2,7 +2,7 @@ require 'src/crawler'
namespace
:db
do
task
populate: :environment
do
# Clawler.make_industries
Clawler
.
make_cities
#
Clawler.make_cities
Clawler
.
make_companies
Clawler
.
make_jobs
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment