Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
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
Mai Hoang Thai Ha
VenJob
Commits
8328deb3
Commit
8328deb3
authored
Jul 27, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed review part 3
parent
cdd2eeb9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
lib/tasks/web_crawler.rake
+21
-24
No files found.
lib/tasks/web_crawler.rake
View file @
8328deb3
...
@@ -29,23 +29,24 @@ namespace :crawler do
...
@@ -29,23 +29,24 @@ namespace :crawler do
update_at
,
job_type
,
salary
,
experience
,
level
,
expiration_date
=
''
update_at
,
job_type
,
salary
,
experience
,
level
,
expiration_date
=
''
industries
=
[]
industries
=
[]
detail_box_items
.
each
do
|
info_item
|
detail_box_items
.
each
do
|
info_item
|
info
=
info_item
.
text
key
=
info_item
.
css
(
'strong'
).
text
.
strip
default_value
=
info_item
.
css
(
'p'
).
text
.
squish
# case/when
# case/when
case
case
key
when
info
.
include?
(
key
=
'Ngày cập nhật'
)
when
'Ngày cập nhật'
update_at
=
info
.
squish
.
remove
(
key
).
strip
.
to_time
update_at
=
default_value
.
to_time
when
info
.
include?
(
key
=
'Ngành nghề'
)
when
'Ngành nghề'
industries
=
info
.
squish
.
remove
(
key
).
strip
.
split
(
' , '
)
industries
=
default_value
.
split
(
' , '
)
when
info
.
include?
(
key
=
'Hình thức'
)
when
'Hình thức'
job_type
=
info
.
squish
.
remove
(
key
).
strip
job_type
=
default_value
when
info
.
include?
(
key
=
'Lương'
)
when
'Lương'
salary
=
info
.
squish
.
remove
(
key
).
strip
salary
=
default_value
when
info
.
include?
(
key
=
'Kinh nghiệm'
)
when
'Kinh nghiệm'
experience
=
info
.
squish
.
remove
(
key
).
strip
experience
=
default_value
.
squish
when
info
.
include?
(
key
=
'Cấp bậc'
)
when
'Cấp bậc'
level
=
info
.
squish
.
remove
(
key
).
strip
level
=
default_value
when
info
.
include?
(
key
=
'Hết hạn nộp'
)
when
'Hết hạn nộp'
expiration_date
=
info
.
squish
.
remove
(
key
).
strip
.
to_time
expiration_date
=
default_value
.
to_time
end
end
end
end
# benefits, description, requirement, other_info
# benefits, description, requirement, other_info
...
@@ -56,13 +57,13 @@ namespace :crawler do
...
@@ -56,13 +57,13 @@ namespace :crawler do
detail_content
=
detail_row
.
css
(
':not(h3.detail-title)'
)
detail_content
=
detail_row
.
css
(
':not(h3.detail-title)'
)
case
detail_title
case
detail_title
when
'Phúc lợi'
when
'Phúc lợi'
benefits
=
get_detail_text
(
detail_content
)
benefits
=
detail_row
.
css
(
'ul.welfare-list li'
).
map
(
&
:text
).
map
(
&
:squish
).
join
(
'---'
)
when
'Mô tả Công việc'
when
'Mô tả Công việc'
description
=
get_detail_text
(
detail_content
)
description
=
detail_content
.
inner_html
when
'Yêu Cầu Công Việc'
when
'Yêu Cầu Công Việc'
requirement
=
get_detail_text
(
detail_content
)
requirement
=
detail_content
.
inner_html
when
'Thông tin khác'
when
'Thông tin khác'
other_info
=
get_detail_text
(
detail_content
)
other_info
=
detail_row
.
css
(
'.content_fck ul li'
).
map
(
&
:text
).
map
(
&
:squish
).
join
(
'---'
)
end
end
end
end
# Company
# Company
...
@@ -124,8 +125,4 @@ namespace :crawler do
...
@@ -124,8 +125,4 @@ namespace :crawler do
)
)
end
end
end
end
def
get_detail_text
(
arr
)
arr
.
map
(
&
:text
).
map
(
&
:squish
)[
1
..-
1
].
reject
(
&
:blank?
).
join
(
'---'
)
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