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
7974b2aa
Commit
7974b2aa
authored
Aug 10, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Append condition in crawl City
parent
cdfa6137
Pipeline
#864
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
lib/src/crawler.rb
+9
-5
No files found.
lib/src/crawler.rb
View file @
7974b2aa
class
Crawler
class
Crawler
VIETNAM
=
0
FOREIGN
=
1
def
initialize
(
logger
,
url
)
def
initialize
(
logger
,
url
)
@logger
=
logger
@logger
=
logger
@url
=
url
@url
=
url
...
@@ -20,11 +22,13 @@ class Crawler
...
@@ -20,11 +22,13 @@ class Crawler
data_city
.
each
do
|
name_city
|
data_city
.
each
do
|
name_city
|
if
City
.
find_by
(
id:
70
)
if
City
.
find_by
(
id:
70
)
city
=
City
.
create!
(
name:
name_city
,
city
=
City
.
find_or_create_by!
(
name:
name_city
)
do
location:
0
)
city
.
update!
(
location:
VIETNAM
)
end
else
else
city
=
City
.
create!
(
name:
name_city
,
city
=
City
.
find_or_create_by!
(
name:
name_city
)
do
location:
1
)
city
.
update!
(
location:
FOREIGN
)
end
end
end
end
end
end
end
...
@@ -35,7 +39,7 @@ class Crawler
...
@@ -35,7 +39,7 @@ class Crawler
data_industry
=
get_name
.
search
(
'option'
).
map
{
|
p
|
p
.
text
.
strip
}
data_industry
=
get_name
.
search
(
'option'
).
map
{
|
p
|
p
.
text
.
strip
}
data_industry
.
each
do
|
name_industry
|
data_industry
.
each
do
|
name_industry
|
industry
=
Industry
.
create
!
(
name:
name_industry
)
industry
=
Industry
.
find_or_create_by
!
(
name:
name_industry
)
end
end
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