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
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
28 deletions
+62
-28
app/assets/stylesheets/custom.scss
+22
-6
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
+12
-3
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
+9
-4
lib/src/interface_web.rb
+7
-2
lib/tasks/crawler.rake
+1
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
36b7290d
...
@@ -236,11 +236,11 @@ $main-color: #221f20;
...
@@ -236,11 +236,11 @@ $main-color: #221f20;
}
}
.slogan_text
{
.slogan_text
{
text-align
:
center
;
text-align
:
center
;
font-family
:
sans-serif
;
font-family
:
'Raleway'
,
sans-serif
;
font-size
:
35px
;
font-size
:
35px
;
color
:
#eaeaea
;
color
:
#eaeaea
;
transform
:
scale
(
1
.35
);
transform
:
scale
(
1
.35
);
font-weight
:
6
00
;
font-weight
:
7
00
;
margin
:
0
;
margin
:
0
;
padding
:
0
;
padding
:
0
;
}
}
...
@@ -670,9 +670,11 @@ $main-color: #221f20;
...
@@ -670,9 +670,11 @@ $main-color: #221f20;
-webkit-box-orient
:
vertical
;
-webkit-box-orient
:
vertical
;
}
}
.box_info_location
{
.box_info_location
{
font-size
:
1
3
px
;
font-size
:
1
4
px
;
color
:
#666
;
color
:
#666
;
margin-top
:
5px
;
margin-top
:
-4px
;
line-height
:
24px
;
}
}
.box_info_salary
{
.box_info_salary
{
font-size
:
13px
;
font-size
:
13px
;
...
@@ -687,7 +689,17 @@ $main-color: #221f20;
...
@@ -687,7 +689,17 @@ $main-color: #221f20;
// background-color: #d41323;
// background-color: #d41323;
}
}
.coc
{
.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%
;
width
:
100%
;
overflow
:
hidden
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
text-overflow
:
ellipsis
;
...
@@ -699,7 +711,7 @@ $main-color: #221f20;
...
@@ -699,7 +711,7 @@ $main-color: #221f20;
.box_info_des
{
.box_info_des
{
width
:
100%
;
width
:
100%
;
font-size
:
12
.5px
;
font-size
:
12
.5px
;
line-height
:
1
2
.5
px
;
line-height
:
1
3
px
;
color
:
#888
;
color
:
#888
;
margin
:
0
;
margin
:
0
;
}
}
...
@@ -817,6 +829,10 @@ $main-color: #221f20;
...
@@ -817,6 +829,10 @@ $main-color: #221f20;
background-color
:
white
;
background-color
:
white
;
}
}
.loc
{
margin-top
:
5px
;
width
:
90%
;
}
.btn_search_submit
{
.btn_search_submit
{
height
:
30px
;
height
:
30px
;
}
}
...
...
app/controllers/home_controller.rb
View file @
36b7290d
...
@@ -3,9 +3,7 @@ class HomeController < ApplicationController
...
@@ -3,9 +3,7 @@ class HomeController < ApplicationController
def
index
def
index
@data_industries
=
Industry
.
sort_asc
.
all
@data_industries
=
Industry
.
sort_asc
.
all
@data_total_job
=
Job
.
all
.
count
@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
@data_cities
=
City
.
all
end
end
end
end
app/models/company.rb
View file @
36b7290d
class
Company
<
ApplicationRecord
class
Company
<
ApplicationRecord
has_many
:jobs
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
end
app/models/job.rb
View file @
36b7290d
...
@@ -12,4 +12,5 @@ class Job < ApplicationRecord
...
@@ -12,4 +12,5 @@ class Job < ApplicationRecord
has_many
:histories
has_many
:histories
has_many
:favorites
has_many
:favorites
end
end
app/views/home/index.html.erb
View file @
36b7290d
<%
provide
(
:title
,
'Trang chủ'
)
%>
<%=
render
'home/banner_and_search'
%>
<%=
render
'home/banner_and_search'
%>
<div
class=
"padding_index"
></div>
<div
class=
"padding_index"
></div>
<div
class=
"box_text_five_jobs"
>
<div
class=
"box_text_five_jobs"
>
...
...
app/views/shared/_box_five_job.html.erb
View file @
36b7290d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<%
i
=
0
%>
<%
@data_five_jobs
.
each
do
|
val
|
%>
<%
@data_five_jobs
.
each
do
|
val
|
%>
<div
class=
"box_jobs"
>
<div
class=
"box_jobs"
>
<div
class=
"col-sm-12 d-block d-sm-none"
>
<div
class=
"col-sm-12 d-block d-sm-none"
>
...
@@ -15,13 +16,21 @@
...
@@ -15,13 +16,21 @@
<div
class=
"col-sm-10 col-md-9 col-lg-10"
>
<div
class=
"col-sm-10 col-md-9 col-lg-10"
>
<div
class=
"box_info"
>
<div
class=
"box_info"
>
<div
class=
"lol"
>
<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"
%>
<%=
image_tag
'trophy'
,
class:
"img_job_name"
%>
</div>
</div>
<div
class =
"cop"
>
<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>
</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>
<h5
class=
"box_info_salary"
><i
class=
"fas fa-dollar-sign"
></i>
Lương:
<%=
val
.
salary
%>
</h5>
<div
class=
"coc"
>
<div
class=
"coc"
>
<h5
class=
"box_info_des"
>
<%=
strip_tags
(
val
.
description
)
%>
</h5>
<h5
class=
"box_info_des"
>
<%=
strip_tags
(
val
.
description
)
%>
</h5>
...
...
config/database.yml
View file @
36b7290d
...
@@ -14,7 +14,7 @@ default: &default
...
@@ -14,7 +14,7 @@ default: &default
encoding
:
utf8
encoding
:
utf8
pool
:
<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool
:
<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username
:
root
username
:
root
password
:
'
1
2345678
'
password
:
'
1'
socket
:
/var/run/mysqld/mysqld.sock
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 @@
...
@@ -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:
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
|
create_table
"applied_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
t
.
bigint
"user_id"
...
@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do
...
@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do
t
.
text
"description"
t
.
text
"description"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
boolean
"newdata"
end
end
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
...
...
lib/src/crawler.rb
View file @
36b7290d
...
@@ -44,12 +44,15 @@ class Clawler
...
@@ -44,12 +44,15 @@ class Clawler
# FILL DATA COMPANIES
# FILL DATA COMPANIES
def
self
.
make_companies
def
self
.
make_companies
Company
.
create!
(
name:
"Company name"
,
Company
.
create!
(
name:
"Company name"
,
address:
"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
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
()
@data
=
Interface_web
.
craw_data_companies
()
i
=
@data
[
:name
].
length
i
=
@data
[
:name
].
length
i
.
times
do
|
n
|
i
.
times
do
|
n
|
name
=
@data
[
:name
][
n
]
name
=
@data
[
:name
][
n
]
if
Company
.
find_by
(
"name = ?"
,
name
)
next
else
address
=
@data
[
:address
][
n
]
address
=
@data
[
:address
][
n
]
short_description
=
@data
[
:description
][
n
]
short_description
=
@data
[
:description
][
n
]
Company
.
create!
(
name:
name
,
Company
.
create!
(
name:
name
,
...
@@ -57,9 +60,10 @@ class Clawler
...
@@ -57,9 +60,10 @@ class Clawler
short_description:
short_description
)
short_description:
short_description
)
end
end
end
end
end
# FILL DATA JOBS
# FILL DATA JOBS
def
self
.
make_jobs
def
self
.
make_jobs
Job
.
update_all
(
newdata:
0
)
@data_jobs
=
Interface_web
.
make_data
()
@data_jobs
=
Interface_web
.
make_data
()
i
=
@data_jobs
[
:name
].
length
i
=
@data_jobs
[
:name
].
length
i
.
times
do
|
n
|
i
.
times
do
|
n
|
...
@@ -85,7 +89,8 @@ class Clawler
...
@@ -85,7 +89,8 @@ class Clawler
salary:
salary
,
salary:
salary
,
create_date:
create_date
,
create_date:
create_date
,
expiration_date:
expiration_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_industries_table
(
@data_jobs
[
:industry_name
][
n
],
id_job
.
id
)
self
.
make_foreign_cities_table
(
@data_jobs
[
:city_name
][
n
],
id_job
.
id
)
self
.
make_foreign_cities_table
(
@data_jobs
[
:city_name
][
n
],
id_job
.
id
)
end
end
...
...
lib/src/interface_web.rb
View file @
36b7290d
...
@@ -21,9 +21,9 @@ class Interface_web
...
@@ -21,9 +21,9 @@ class Interface_web
data
<<
website_companies
<<
website_jobs
data
<<
website_companies
<<
website_jobs
end
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
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
end
def
self
.
base_link
(
url
)
def
self
.
base_link
(
url
)
...
@@ -255,6 +255,7 @@ class Interface_web
...
@@ -255,6 +255,7 @@ class Interface_web
end
end
def
self
.
make_data
def
self
.
make_data
puts
'Please wait for crawl jobs data! . . .'
@data
=
{}
@data
=
{}
@name
=
[]
@name
=
[]
@company_name
=
[]
@company_name
=
[]
...
@@ -268,6 +269,8 @@ class Interface_web
...
@@ -268,6 +269,8 @@ class Interface_web
@city_name
=
[]
@city_name
=
[]
link_crawl
=
get_link_job_and_companies
link_crawl
=
get_link_job_and_companies
total_jobs
=
link_crawl
[
1
].
length
current_job
=
1
link_crawl
[
1
].
each
do
|
path
|
link_crawl
[
1
].
each
do
|
path
|
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
parse
(
URI
.
escape
(
"https://careerbuilder.vn/
#{
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
if
page
.
search
(
".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p"
)[
0
]
!=
nil
...
@@ -275,6 +278,8 @@ class Interface_web
...
@@ -275,6 +278,8 @@ class Interface_web
elsif
page
.
search
(
".DetailJobNew ul li"
).
size
==
10
elsif
page
.
search
(
".DetailJobNew ul li"
).
size
==
10
crawl_data_jobs_interface_5
(
path
)
crawl_data_jobs_interface_5
(
path
)
end
end
puts
"Process:
#{
current_job
}
/
#{
total_jobs
}
"
current_job
+=
1
end
end
@data
@data
end
end
...
...
lib/tasks/crawler.rake
View file @
36b7290d
...
@@ -2,7 +2,7 @@ require 'src/crawler'
...
@@ -2,7 +2,7 @@ require 'src/crawler'
namespace
:db
do
namespace
:db
do
task
populate: :environment
do
task
populate: :environment
do
# Clawler.make_industries
# Clawler.make_industries
Clawler
.
make_cities
#
Clawler.make_cities
Clawler
.
make_companies
Clawler
.
make_companies
Clawler
.
make_jobs
Clawler
.
make_jobs
end
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