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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
61ab1820
Commit
61ab1820
authored
Jul 23, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logger, crontab
parent
c4c8c656
Pipeline
#695
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletions
+34
-1
Gemfile
+1
-0
Gemfile.lock
+4
-0
config/schedule.rb
+25
-0
lib/tasks/crawler.rake
+4
-1
No files found.
Gemfile
View file @
61ab1820
...
...
@@ -64,4 +64,5 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
##
gem
"
nokogiri
"
gem
'
whenever
'
,
require:
false
##
Gemfile.lock
View file @
61ab1820
...
...
@@ -64,6 +64,7 @@ GEM
chromedriver-helper (2.1.1)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chronic (0.10.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
...
...
@@ -187,6 +188,8 @@ GEM
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
...
...
@@ -214,6 +217,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
whenever
RUBY VERSION
ruby 2.6.6p146
...
...
config/schedule.rb
0 → 100755
View file @
61ab1820
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_method"
# rake "some:great:rake:task"
# end
#
# every 4.days do
# runner "AnotherModel.prune_old_records"
# end
# Learn more: http://github.com/javan/whenever
env
:PATH
,
ENV
[
'PATH'
]
every
5
.
minutes
do
rake
'crawl:crawl_industries_locations_jobs[1]'
end
\ No newline at end of file
lib/tasks/crawler.rake
View file @
61ab1820
require
"open-uri"
@logger
||=
Logger
.
new
(
"
#{
Rails
.
root
}
/log/crawler.log"
)
namespace
:crawl
do
desc
"crawl industries locations jobs"
...
...
@@ -7,7 +8,7 @@ namespace :crawl do
crawl_industries_and_locations
job_links
=
get_job_links
(
args
[
:page
].
to_i
,
args
[
:link
])
job_links
.
each
do
|
link
|
break
if
link
.
empty?
next
if
link
.
empty?
crawl_job
(
link
)
end
end
...
...
@@ -43,6 +44,7 @@ def crawl_company(company_link)
end
rescue
=>
exception
puts
exception
@logger
.
error
"
#{
exception
.
message
}
- Company link:
#{
uri
}
"
return
end
end
...
...
@@ -83,6 +85,7 @@ def crawl_job(job_link)
puts
job_title
rescue
=>
exception
puts
exception
@logger
.
error
"
#{
exception
.
message
}
- Job link:
#{
uri
}
"
return
exception
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