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
e080cf4f
Commit
e080cf4f
authored
Jul 23, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crawler
parent
99daf536
Pipeline
#1361
canceled with stages
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
db/migrate/20210720145646_change_jobs.rb
+2
-2
db/schema.rb
+2
-2
lib/tasks/crawler.rake
+11
-8
No files found.
db/migrate/20210720145646_change_jobs.rb
View file @
e080cf4f
class
ChangeJobs
<
ActiveRecord
::
Migration
[
6.1
]
class
ChangeJobs
<
ActiveRecord
::
Migration
[
6.1
]
def
up
def
up
change_column
:jobs
,
:
salary
,
:string
change_column
:jobs
,
:
experience
,
:string
end
end
def
down
def
down
change_column
:jobs
,
:
salary
,
:integer
change_column
:jobs
,
:
experience
,
:integer
end
end
end
end
db/schema.rb
View file @
e080cf4f
...
@@ -97,9 +97,9 @@ ActiveRecord::Schema.define(version: 2021_07_23_035105) do
...
@@ -97,9 +97,9 @@ ActiveRecord::Schema.define(version: 2021_07_23_035105) do
t
.
text
"requirement"
t
.
text
"requirement"
t
.
text
"other_requirement"
t
.
text
"other_requirement"
t
.
string
"salary"
t
.
string
"salary"
t
.
string
"type"
t
.
string
"
job_
type"
t
.
string
"level"
t
.
string
"level"
t
.
integer
"experience"
t
.
string
"experience"
t
.
string
"benefits"
t
.
string
"benefits"
t
.
datetime
"expired_at"
t
.
datetime
"expired_at"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
...
...
lib/tasks/crawler.rake
View file @
e080cf4f
...
@@ -57,11 +57,11 @@ namespace :crawler do
...
@@ -57,11 +57,11 @@ namespace :crawler do
salary
,
experience
,
type
,
level
,
expired_at
=
''
salary
,
experience
,
type
,
level
,
expired_at
=
''
detail_content
=
detail_job
.
css
(
'div.row div.detail-box.has-background ul li'
)
detail_content
=
detail_job
.
css
(
'div.row div.detail-box.has-background ul li'
)
detail_content
.
each
do
|
content
|
detail_content
.
each
do
|
content
|
case
content
.
css
(
'strong'
).
text
case
content
.
css
(
'strong'
).
text
.
strip
when
'Lương'
when
'Lương'
salary
=
content
.
css
(
'p'
).
text
salary
=
content
.
css
(
'p'
).
text
when
'Kinh nghiệm'
when
'Kinh nghiệm'
experience
=
content
.
css
(
'p'
).
text
experience
=
content
.
css
(
'p'
).
text
.
gsub
(
'\r\n'
,
''
).
strip
when
'Hình thức'
when
'Hình thức'
type
=
content
.
css
(
'p'
).
text
type
=
content
.
css
(
'p'
).
text
when
'Cấp bậc'
when
'Cấp bậc'
...
@@ -89,7 +89,7 @@ namespace :crawler do
...
@@ -89,7 +89,7 @@ namespace :crawler do
title:
title
.
text
,
title:
title
.
text
,
salary:
salary
,
salary:
salary
,
experience:
experience
,
experience:
experience
,
type:
type
,
job_
type:
type
,
level:
level
,
level:
level
,
expired_at:
expired_at
,
expired_at:
expired_at
,
benefits:
benefits
,
benefits:
benefits
,
...
@@ -103,19 +103,22 @@ namespace :crawler do
...
@@ -103,19 +103,22 @@ namespace :crawler do
industries
=
detail_job
.
css
(
'div.detail-box.has-background ul li p a'
)
industries
=
detail_job
.
css
(
'div.detail-box.has-background ul li p a'
)
industries
.
each
do
|
industry
|
industries
.
each
do
|
industry
|
name
=
industry
.
text
.
squish
name
=
industry
.
text
.
squish
job_industries
<<
Industry
.
find_by
(
name:
name
)
job_industry
=
Industry
.
find_by
(
name:
name
)
end
next
if
job_industry
.
nil?
next
if
job_industries
.
nil?
job_industries
<<
job_industry
end
job
.
industries
<<
job_industries
job
.
industries
<<
job_industries
job_cities
=
[]
job_cities
=
[]
location
=
detail_job
.
css
(
'div.map p a'
)
location
=
detail_job
.
css
(
'div.map p a'
)
location
.
each
do
|
city
|
location
.
each
do
|
city
|
name
=
city
.
text
name
=
city
.
text
job_cities
<<
City
.
find_by
(
name:
name
)
job_city
=
City
.
find_by
(
name:
name
)
next
if
job_city
.
nil?
job_cities
<<
job_city
end
end
next
if
job_cities
.
nil?
job
.
cities
<<
job_cities
job
.
cities
<<
job_cities
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