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
bcb0e409
Commit
bcb0e409
authored
Jul 15, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create crawler
parent
6a2e0164
Pipeline
#1350
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
craw.rb
+42
-0
No files found.
craw.rb
0 → 100644
View file @
bcb0e409
require
'nokogiri'
require
'open-uri'
require
'byebug'
def
scraper
base_url
=
Nokogiri
::
HTML
(
URI
.
open
(
'https://careerbuilder.vn/'
))
#doc va parse url tat ca cac job
list_url
=
base_url
.
css
(
'div.menu div.dropdown-menu ul li a'
)[
0
].
attributes
[
"href"
].
value
list_url_job
=
Nokogiri
::
HTML
(
URI
.
open
(
list_url
))
job_listing
=
list_url_job
.
css
(
'div.job-item'
)
page
=
1
per_page
=
job_listing
.
count
total
=
list_url_job
.
css
(
'div.job-found p'
).
text
.
split
(
' '
)[
0
].
gsub
(
','
,
''
).
to_i
last_page
=
(
total
.
to_f
/
per_page
.
to_f
).
round
while
page
<=
last_page
pagination_list_url
=
"https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-
#{
page
}
-vi.html"
pagination_list_url_job
=
Nokogiri
::
HTML
(
URI
.
open
(
pagination_list_url
))
pagination_job_listing
=
pagination_list_url_job
.
css
(
'div.job-item'
)
pagination_url
=
pagination_job_listing
.
css
(
'a'
)[
1
].
attributes
[
"href"
].
value
pagination_detail_url
=
Nokogiri
::
HTML
(
URI
.
open
(
pagination_url
))
pagination_detail_job
=
pagination_detail_url
.
css
(
'div.container'
)
job
=
{
title:
pagination_detail_job
.
css
(
'div.job-desc h1.title'
)[
0
].
text
,
company:
pagination_detail_job
.
css
(
'div.job-desc a'
)[
0
].
text
,
salary:
pagination_detail_job
.
css
(
'div.detail-box.has-background ul li p'
)[
3
].
text
,
type:
pagination_detail_job
.
css
(
'div.detail-box.has-background ul li p'
)[
2
].
text
,
experience:
pagination_detail_job
.
css
(
'div.detail-box.has-background ul li p'
)[
4
].
text
.
gsub
(
"
\r\n
"
,
""
).
strip
,
level:
pagination_detail_job
.
css
(
'div.detail-box.has-background ul li p'
)[
5
].
text
,
expired_at:
pagination_detail_job
.
css
(
'div.detail-box.has-background ul li p'
)[
6
].
text
,
benefits:
pagination_detail_job
.
css
(
'div.detail-row'
)[
0
].
text
.
gsub
(
"
\r\n
"
,
""
).
strip
,
overview:
pagination_detail_job
.
css
(
'div.detail-row'
)[
1
].
text
.
gsub
(
"
\r\n
"
,
""
).
strip
,
requirement:
pagination_detail_job
.
css
(
'div.detail-row'
)[
2
].
text
.
gsub
(
"
\r\n
"
,
""
).
strip
,
other_requirement:
pagination_detail_job
.
css
(
'div.detail-row'
)[
2
].
text
.
gsub
(
/\s+/
,
" "
)
}
page
+=
1
end
byebug
end
scraper
\ No newline at end of file
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