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
f5d71986
Commit
f5d71986
authored
Jul 22, 2020
by
Ngo Trung Hung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crawler
parent
81cfe475
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
26 deletions
+28
-26
app/assets/stylesheets/custom.scss
+3
-3
app/models/city.rb
+1
-1
app/views/shared/_block_cities_hot.html.erb
+3
-3
app/views/shared/_box_five_job.html.erb
+1
-3
app/views/shared/_box_nine_city.html.erb
+1
-1
lib/src/crawler.rb
+16
-12
lib/src/interface_web.rb
+0
-0
lib/tasks/crawler.rake
+3
-3
No files found.
app/assets/stylesheets/custom.scss
View file @
f5d71986
...
@@ -687,7 +687,6 @@ $main-color: #221f20;
...
@@ -687,7 +687,6 @@ $main-color: #221f20;
.box_info_salary
{
.box_info_salary
{
font-size
:
13px
;
font-size
:
13px
;
color
:
#008563
;
color
:
#008563
;
font-weight
:
600
;
transform
:
translateY
(
-2px
);
transform
:
translateY
(
-2px
);
}
}
.box_btn_favotite
{
.box_btn_favotite
{
...
@@ -818,7 +817,7 @@ $main-color: #221f20;
...
@@ -818,7 +817,7 @@ $main-color: #221f20;
}
}
.box_text_five_jobs.box_padding_city
{
.box_text_five_jobs.box_padding_city
{
background-
color
:
#da6d2e
;
background-
image
:
linear-gradient
(
to
right
,
#86cb49
,
#169b74
,
#86cb49
);
color
:
white
;
color
:
white
;
font-weight
:
600
;
font-weight
:
600
;
margin-bottom
:
0px
!
important
;
margin-bottom
:
0px
!
important
;
...
@@ -849,12 +848,13 @@ $main-color: #221f20;
...
@@ -849,12 +848,13 @@ $main-color: #221f20;
cursor
:
pointer
;
cursor
:
pointer
;
color
:
white
;
color
:
white
;
text-align
:
center
;
text-align
:
center
;
font-size
:
1
8
px
;
font-size
:
1
7
px
;
font-weight
:
bold
;
font-weight
:
bold
;
}
}
.ct_jobs_count
{
.ct_jobs_count
{
cursor
:
pointer
;
cursor
:
pointer
;
font-size
:
16px
;
text-align
:
center
;
text-align
:
center
;
color
:
#999
;
color
:
#999
;
}
}
...
...
app/models/city.rb
View file @
f5d71986
...
@@ -6,7 +6,7 @@ class City < ApplicationRecord
...
@@ -6,7 +6,7 @@ class City < ApplicationRecord
hash
=
{}
hash
=
{}
data_cities
=
City
.
all
data_cities
=
City
.
all
data_cities
.
each
do
|
val
|
data_cities
.
each
do
|
val
|
hash
[
val
.
id
]
=
val
.
jobs
.
count
hash
[
val
.
name
]
=
val
.
jobs
.
count
end
end
hash
.
sort_by
{
|
k
,
v
|
v
}.
reverse
hash
.
sort_by
{
|
k
,
v
|
v
}.
reverse
end
end
...
...
app/views/shared/_block_cities_hot.html.erb
View file @
f5d71986
<div
class=
"box_info_city"
>
<div
class=
"box_info_city"
>
<div
class=
"ct_name"
>
<div
class=
"ct_name"
>
<%
data
=
City
.
find
(
k
)
%>
<%=
link_to
name_city
,
'#'
,
class:
'link_ct'
%>
<%=
link_to
data
.
name
,
'#'
,
class:
'link_ct'
%>
</div>
</div>
<div
class=
"ct_jobs_count"
>
<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>
</div>
</div>
\ No newline at end of file
app/views/shared/_box_five_job.html.erb
View file @
f5d71986
...
@@ -6,11 +6,9 @@
...
@@ -6,11 +6,9 @@
<%
@five_jobs
.
each
do
|
val
|
%>
<%
@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"
>
<button
type=
"submit"
class=
"btn_favorite_outline xs"
>
<button
type=
"submit"
class=
"btn_favorite_outline xs"
>
<i
class=
"far fa-heart"
></i>
<i
class=
"far fa-heart"
></i>
</button>
</button>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-10 col-md-9 col-lg-10"
>
<div
class=
"col-sm-10 col-md-9 col-lg-10"
>
...
@@ -31,7 +29,7 @@
...
@@ -31,7 +29,7 @@
<%=
dt
.
join
(
''
).
chomp
(
'| '
)
%>
<%=
dt
.
join
(
''
).
chomp
(
'| '
)
%>
</h5>
</h5>
</div>
</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>
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>
</div>
</div>
...
...
app/views/shared/_box_nine_city.html.erb
View file @
f5d71986
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<div
class=
"row no-gutters"
>
<div
class=
"row no-gutters"
>
<%
@top_city
.
each
do
|
k
,
v
|
%>
<%
@top_city
.
each
do
|
k
,
v
|
%>
<div
class=
"col-lg-4 col-md-4 col-sm-6 col-xs-12"
>
<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>
</div>
<%
end
%>
<%
end
%>
<div
class=
"col-lg-4 col-md-4 col-sm-6 col-xs-12"
>
<div
class=
"col-lg-4 col-md-4 col-sm-6 col-xs-12"
>
...
...
lib/src/crawler.rb
View file @
f5d71986
...
@@ -12,7 +12,7 @@ class Clawler
...
@@ -12,7 +12,7 @@ class Clawler
list_cities
.
each
do
|
x
|
list_cities
.
each
do
|
x
|
data_list_cities
<<
x
.
gsub
(
/(^<[\w\D]*>)/
,
''
).
gsub
(
/\n/
,
''
).
rstrip
data_list_cities
<<
x
.
gsub
(
/(^<[\w\D]*>)/
,
''
).
gsub
(
/\n/
,
''
).
rstrip
end
end
puts
"Save data to database...
\n
"
puts
"Save data to database...
\n
------------------------
"
data_list_cities
.
length
.
times
do
|
i
|
data_list_cities
.
length
.
times
do
|
i
|
area
=
i
>
69
?
0
:
1
area
=
i
>
69
?
0
:
1
name
=
(
data_list_cities
[
i
].
to_s
)
name
=
(
data_list_cities
[
i
].
to_s
)
...
@@ -29,7 +29,7 @@ class Clawler
...
@@ -29,7 +29,7 @@ class Clawler
list_industries
.
each
do
|
x
|
list_industries
.
each
do
|
x
|
data_list_industries
<<
x
.
gsub
(
/(^<[\w\D]*>)/
,
''
).
gsub
(
/\n/
,
''
).
strip
data_list_industries
<<
x
.
gsub
(
/(^<[\w\D]*>)/
,
''
).
gsub
(
/\n/
,
''
).
strip
end
end
puts
"Save data to database...
\n
"
puts
"Save data to database...
\n
------------------------
"
data_list_industries
.
length
.
times
do
|
i
|
data_list_industries
.
length
.
times
do
|
i
|
name
=
data_list_industries
[
i
].
to_s
name
=
data_list_industries
[
i
].
to_s
if
name
.
include?
(
'&'
)
if
name
.
include?
(
'&'
)
...
@@ -39,23 +39,27 @@ class Clawler
...
@@ -39,23 +39,27 @@ class Clawler
end
end
end
end
# FILL DATA COMPANIES
# FILL DATA COMPANIES
def
self
.
make_companies
def
self
.
make_companies
Company
.
create!
(
name:
"Bảo mật"
,
# Company.create!(name: "Bảo mật",
address:
"Vui lòng xem 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"
)
# 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
()
@data
=
Interface_web
.
craw_data_companies
()
puts
'Save info companies to database . . .'
puts
'Save info companies to database . . .'
i
=
0
@data
[
:name
].
each_with_index
do
|
name
,
index
|
@data
[
:name
].
each
do
|
n
|
if
Company
.
find_by
(
name:
name
).
blank?
if
Company
.
find_by
(
name:
n
).
blank?
address
=
@data
[
:address
][
index
]
address
=
@data
[
:address
][
i
]
short_description
=
@data
[
:description
][
index
]
short_description
=
@data
[
:description
][
i
]
Company
.
create!
(
name:
name
,
Company
.
create!
(
name:
n
,
address:
address
,
address:
address
,
short_description:
short_description
)
short_description:
short_description
)
end
end
i
+=
1
end
end
end
end
# FILL DATA JOBS
# FILL DATA JOBS
...
...
lib/src/interface_web.rb
View file @
f5d71986
This diff is collapsed.
Click to expand it.
lib/tasks/crawler.rake
View file @
f5d71986
require
'src/crawler'
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
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