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
Huỳnh Thiên Phước
venjob
Commits
c002193c
Commit
c002193c
authored
Aug 03, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change file crawler
parent
0bdc8e73
Pipeline
#770
failed with stages
in 0 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
10 deletions
+36
-10
app/controllers/top_pages_controller.rb
+2
-0
app/views/layouts/_search_bar.html.erb
+25
-0
app/views/top_pages/index.html.erb
+3
-2
lib/src/crawler.rb
+3
-3
lib/src/csvimporter.rb
+0
-2
lib/src/jobparser.rb
+2
-2
lib/tasks/crawler_import.rake
+1
-1
No files found.
app/controllers/top_pages_controller.rb
View file @
c002193c
class
TopPagesController
<
ApplicationController
def
index
@cities
=
City
.
all
@industries
=
Industry
.
all
@total_jobs
=
Job
.
count
@jobs
=
Job
.
limit
(
5
).
order
(
created_at: :desc
)
@jobs_of_cities
=
CityJob
.
top_city
...
...
app/views/layouts/_search_bar.html.erb
View file @
c002193c
<div
class=
"search-bar"
>
<div
class=
"row"
>
<div
class=
"col-sm"
>
<input
class=
"form-control mr-sm-2"
type=
"search"
placeholder=
"Search"
aria-label=
"Search"
>
</div>
<div
class=
"col-sm"
>
<select
class=
"form-control"
id=
"exampleFormControlSelect1"
>
<%=
@cities
.
each
do
|
city
|
%>
<option>
<%=
city
.
name
%>
</option>
<%
end
%>
</select>
</div>
<div
class=
"col-sm"
>
<select
class=
"form-control"
id=
"exampleFormControlSelect1"
>
<%=
@industries
.
each
do
|
industry
|
%>
<option>
<%=
industry
.
name
%>
</option>
<%
end
%>
</select>
</div>
<div
class=
"col-2-sm"
>
<button
class=
"btn btn-primary"
type=
"submit"
>
Search
</button>
</div>
</div>
</div>
\ No newline at end of file
app/views/top_pages/index.html.erb
View file @
c002193c
...
...
@@ -4,9 +4,10 @@
<div
class=
"total-job"
>
Having
<%=
@total_jobs
%>
jobs for you!
</div>
</div>
</div>
<div
class=
"search-bar"
>
<%=
render
'layouts/search_bar'
%>
</div>
<br>
<div
class=
"container"
>
<div
class=
"search-bar"
>
<%=
render
'layouts/search_bar'
%>
</div>
<br>
<div
class=
"job-list"
>
<%=
render
'layouts/show_jobs'
%>
</div>
<div
class=
"city-banner rounded"
>
City
</div>
...
...
lib/src/crawler.rb
View file @
c002193c
...
...
@@ -81,7 +81,7 @@ class Crawler
next
if
link
==
'javascript:void(0);'
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
escape
(
link
)))
name
=
page
.
search
(
'p.name'
)
&
.
text
return
if
name
.
blank?
next
if
name
.
blank?
address
=
page
.
css
(
'div.content p'
).
children
[
1
]
&
.
text
introduction
=
page
.
css
(
'div.main-about-us'
).
text
...
...
@@ -99,8 +99,8 @@ class Crawler
def
crawl_job
(
1
..
10
).
each
do
|
n
|
info
=
Nokogiri
::
HTML
(
URI
.
open
(
"https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-
#{
n
}
-vi.html"
))
link
=
info
.
css
(
'a.job_link'
).
map
{
|
link
|
link
[
'href'
]
}
link
.
each
do
|
link
|
link
s
=
info
.
css
(
'a.job_link'
).
map
{
|
link
|
link
[
'href'
]
}
link
s
.
each
do
|
link
|
link_page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
escape
(
link
)))
row
=
link_page
.
search
(
'div.bg-blue div.row'
)
next
if
row
.
blank?
...
...
lib/src/csvimporter.rb
View file @
c002193c
...
...
@@ -60,7 +60,6 @@ class CSVimporter
industry_name
=
row
[
"category"
]
industries_relationship
=
Industry
.
where
(
name:
industry_name
)
if
industries_relationship
.
blank?
industry
=
Industry
.
create!
(
name:
industry_name
)
industries_relationship
=
Industry
.
where
(
name:
industry
)
job
.
industries
<<
industries_relationship
else
...
...
@@ -71,7 +70,6 @@ class CSVimporter
location
=
location_data
.
gsub
(
'["'
,
''
).
gsub
(
'"]'
,
''
)
location_relationship
=
City
.
where
(
name:
location
)
if
location_relationship
.
blank?
city
=
City
.
create!
(
name:
location
)
location_relationship
=
City
.
where
(
name:
city
)
job
.
cities
<<
location_relationship
else
...
...
lib/src/jobparser.rb
View file @
c002193c
...
...
@@ -17,7 +17,7 @@ class JobParser
next
if
link
==
'javascript:void(0);'
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
escape
(
link
)))
name
=
page
.
search
(
'p.name'
)
&
.
text
return
if
name
.
blank?
next
if
name
.
blank?
address
=
page
.
css
(
'div.content p'
).
children
[
1
]
&
.
text
introduction
=
page
.
css
(
'div.main-about-us'
).
text
...
...
@@ -85,6 +85,6 @@ class JobParser
@logger
.
error
e
.
message
end
end
end
end
lib/tasks/crawler_import.rake
View file @
c002193c
...
...
@@ -21,6 +21,6 @@ namespace :import do
end
def
url
'https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-1-vi.html'
'https://careerbuilder.vn/viec-lam/tat-ca-viec-lam-trang-1-vi.html'
.
freeze
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