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
2
Merge Requests
2
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
Thanh Hung Pham
veNJOB
Commits
d6fa267c
Commit
d6fa267c
authored
Jun 29, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fig bug: convert string to date
parent
0cef5747
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
db/schema.rb
+3
-0
lib/tasks/crawler_data.rake
+3
-3
No files found.
db/schema.rb
View file @
d6fa267c
...
@@ -28,6 +28,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
...
@@ -28,6 +28,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
t
.
string
"name"
t
.
string
"name"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"name"
],
name:
"index_areas_on_name"
end
end
create_table
"categories"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
create_table
"categories"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
...
@@ -42,6 +43,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
...
@@ -42,6 +43,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"area_id"
],
name:
"index_cities_on_area_id"
t
.
index
[
"area_id"
],
name:
"index_cities_on_area_id"
t
.
index
[
"name"
],
name:
"index_cities_on_name"
end
end
create_table
"companies"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
create_table
"companies"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
...
@@ -115,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
...
@@ -115,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170628020034) do
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
t
.
index
[
"contact_id"
],
name:
"index_jobs_on_contact_id"
t
.
index
[
"contact_id"
],
name:
"index_jobs_on_contact_id"
t
.
index
[
"job_type_id"
],
name:
"index_jobs_on_job_type_id"
t
.
index
[
"job_type_id"
],
name:
"index_jobs_on_job_type_id"
t
.
index
[
"name"
],
name:
"index_jobs_on_name"
end
end
create_table
"users"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
create_table
"users"
,
force: :cascade
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
do
|
t
|
...
...
lib/tasks/crawler_data.rake
View file @
d6fa267c
...
@@ -50,7 +50,7 @@ namespace :crawler_data do
...
@@ -50,7 +50,7 @@ namespace :crawler_data do
company_description
=
doc_job_details
.
xpath
(
"//div[@class='desc_company content_fck']"
).
text
.
strip
# Company description
company_description
=
doc_job_details
.
xpath
(
"//div[@class='desc_company content_fck']"
).
text
.
strip
# Company description
Company
.
new
(
name:
company_name
,
address:
company_address
,
description:
company_description
).
save
if
Company
.
where
(
name:
company_name
).
blank?
Company
.
new
(
name:
company_name
,
address:
company_address
,
description:
company_description
).
save
if
Company
.
where
(
name:
company_name
).
blank?
Job
Information
#
Job Information
job_name
=
doc_job_details
.
xpath
(
"//div[@class='LeftJobCB']/div[@class='top-job']/div[@class='top-job-info']/h1"
).
text
.
strip
# Job name
job_name
=
doc_job_details
.
xpath
(
"//div[@class='LeftJobCB']/div[@class='top-job']/div[@class='top-job-info']/h1"
).
text
.
strip
# Job name
job_description
=
doc_job_details
.
xpath
(
"//div[@class='MarBot20']"
).
text
.
strip
# Job description
job_description
=
doc_job_details
.
xpath
(
"//div[@class='MarBot20']"
).
text
.
strip
# Job description
...
@@ -65,13 +65,13 @@ namespace :crawler_data do
...
@@ -65,13 +65,13 @@ namespace :crawler_data do
job_category
=
doc_job_details
.
xpath
(
"//ul[@class='DetailJobNew']/li/p[span/text()='Ngành nghề: ']/b/a[@itemprop='industry']"
).
text
.
strip
job_category
=
doc_job_details
.
xpath
(
"//ul[@class='DetailJobNew']/li/p[span/text()='Ngành nghề: ']/b/a[@itemprop='industry']"
).
text
.
strip
job_expiry_date
=
doc_job_details
.
xpath
(
"//ul[@class='DetailJobNew']/li/p[span/text()='Hết hạn nộp: ']/text()"
)
job_expiry_date
=
doc_job_details
.
xpath
(
"//ul[@class='DetailJobNew']/li/p[span/text()='Hết hạn nộp: ']/text()"
)
.
to_s
Job
.
new
(
name:
job_name
,
description:
job_description
,
Job
.
new
(
name:
job_name
,
description:
job_description
,
salary:
job_salary
,
salary:
job_salary
,
city:
City
.
find_by_name
(
job_location
),
city:
City
.
find_by_name
(
job_location
),
level:
job_level
,
experience:
job_experience
,
status:
0
,
level:
job_level
,
experience:
job_experience
,
status:
0
,
expiry_date:
job_expiry_date
.
to_datetime
.
strftime
(
'%Q'
)
).
save
expiry_date:
job_expiry_date
.
to_datetime
).
save
job_category
.
split
(
','
).
each
do
|
category
|
job_category
.
split
(
','
).
each
do
|
category
|
JobCategory
.
new
(
job:
Job
.
find_by_name
(
job_name
),
category:
Category
.
find_by_name
(
category
)).
save
JobCategory
.
new
(
job:
Job
.
find_by_name
(
job_name
),
category:
Category
.
find_by_name
(
category
)).
save
...
...
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