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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
9794ac57
Commit
9794ac57
authored
Jul 22, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
8b4266e4
Pipeline
#1356
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
lib/tasks/crawler.rake
+14
-9
No files found.
lib/tasks/crawler.rake
View file @
9794ac57
...
...
@@ -14,18 +14,21 @@ namespace :crawler do
while
page
<=
last_page
pagination_page_job
=
"https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-
#{
page
}
-vi.html"
parse_pagination_page_job
=
Nokogiri
::
HTML
(
URI
.
open
(
pagination_page_job
))
parse_pagination_page_job
=
Nokogiri
::
HTML
(
URI
.
open
(
pagination_page_job
))
pagination_job_listing
=
parse_pagination_page_job
.
css
(
'div.job-item'
)
pagination_job_listing
.
each
do
|
detail_jobs
|
company_page
=
detail_jobs
.
css
(
'a.company-name'
).
attribute
(
'href'
).
value
parse_company_url
=
Nokogiri
::
HTML
(
URI
.
open
(
company_page
))
company
=
parse_company_url
.
css
(
'div.container'
)
company_url
=
detail_jobs
.
css
(
'a.company-name'
).
attribute
(
'href'
).
text
next
if
company_url
==
'javascript:void(0);'
slug_company
=
CGI
.
escape
(
company_url
.
gsub
(
'https://careerbuilder.vn/vi/nha-tuyen-dung/'
,
''
).
strip
)
company_page
=
"https://careerbuilder.vn/vi/viec-lam/
#{
slug_company
}
"
puts
company_page
parse_company_page
=
Nokogiri
::
HTML
(
URI
.
open
(
company_page
))
company
=
parse_company_page
.
css
(
'div.container'
)
company_name
=
company
.
css
(
'div.company-info div.content p.name'
)
next
if
company_name
.
nil?
name
=
company
.
css
(
'div.company-info div.content p.name'
).
text
company_info
=
company
.
css
(
'div.company-info div.content'
)
address
=
company_info
.
css
(
'p'
)[
1
].
t
ext
address
=
company_info
.
css
(
'p'
)[
1
].
t
ry
(
:text
)
description
=
company_info
.
css
(
'ul li'
).
text
overview
=
company
.
css
(
'div.row div.content p'
).
text
.
gsub
(
/\s+/
,
''
).
strip
Company
.
find_or_create_by
(
...
...
@@ -35,10 +38,12 @@ namespace :crawler do
overview:
overview
)
job_detail_page
=
detail_jobs
.
css
(
'a.job_link'
).
attribute
(
'href'
).
value
slug_job
=
CGI
.
escape
(
detail_jobs
.
css
(
'a.job_link'
).
attribute
(
'href'
).
text
.
gsub
(
'https://careerbuilder.vn/vi/viec-lam/'
,
''
).
strip
)
job_detail_page
=
"https://careerbuilder.vn/vi/viec-lam/
#{
slug_job
}
"
puts
job_detail_page
parse_job_detail_page
=
Nokogiri
::
HTML
(
URI
.
open
(
job_detail_page
))
detail_job
=
parse_job_detail_page
.
css
(
'div.container'
)
title
=
detail_job
.
css
(
'div.job-desc h1.title'
)
next
if
title
.
nil?
title_job
=
detail_job
.
css
(
'div.job-desc h1.title'
).
text
...
...
@@ -54,7 +59,7 @@ namespace :crawler do
when
'Cấp bậc'
level
=
content
.
css
(
'p'
).
text
.
gsub
(
/\s+/
,
''
).
strip
when
'Ngành nghề'
industry_type
=
content
.
css
(
'p a'
).
text
.
split
(
'/'
)
puts
content
.
css
(
'p a'
).
text
.
split
(
'/'
)
when
'Hết hạn nộp'
expired_at
=
content
.
css
(
'p'
).
text
.
gsub
(
/\s+/
,
''
).
strip
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