Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대선
/
Recruitment_Information_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대선
2021-05-08 18:39:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4cc6b0846ede7d4acf4b9128096340fd18aa5db1
4cc6b084
1 parent
69d97e09
cheerio, sanitize-html 설치 및 네이버 채용정보 데이터를 받아와서, 항목별로 나누기 까지 구현
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
router/naver.js
router/naver.js
0 → 100644
View file @
4cc6b08
const
express
=
require
(
'express'
)
const
router
=
express
.
Router
()
const
puppeteer
=
require
(
'puppeteer'
)
const
cheerio
=
require
(
'cheerio'
)
const
sanitizeHtml
=
require
(
'sanitize-html'
)
const
splitData
=
(
string
)
=>
{
return
string
.
replace
(
/
(
<
([^
>
]
+
)
>
)
*
(\\
t
)?
/gi
,
""
).
split
(
"\t"
).
filter
((
ele
)
=>
ele
!=
''
)
}
const
makeObject
=
(
array
)
=>
{
const
result
=
[];
for
(
let
i
of
array
){
result
.
push
(
splitData
(
i
))
}
return
result
}
router
.
get
(
'/'
,
(
req
,
res
,
error
)
=>
{
res
.
send
(
"naver home"
)
})
router
.
get
(
'/recruitment'
,
async
(
req
,
res
,
error
)
=>
{
const
browser
=
await
puppeteer
.
launch
();
const
page
=
await
browser
.
newPage
();
await
page
.
goto
(
'https://recruit.navercorp.com/naver/job/list/developer'
)
let
content
=
await
page
.
content
()
let
temp
=
null
;
while
(
true
){
if
(
temp
==
content
)
break
;
else
{
temp
=
await
page
.
content
()
await
page
.
click
(
'#moreDiv > button'
).
catch
((
error
)
=>
{
})
await
page
.
waitForTimeout
(
300
)
content
=
await
page
.
content
()
}
}
let
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
})
const
selector
=
'#jobListDiv > ul > li'
let
result
=
sanitizeHtml
(
$
(
selector
),
{
parser
:
{
decodeEntities
:
true
}
})
resArr
=
result
.
split
(
'</li><li>'
)
result
=
makeObject
(
resArr
)
console
.
log
(
result
)
res
.
send
(
result
)
})
module
.
exports
=
router
\ No newline at end of file
Please
register
or
login
to post a comment