Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김진우
/
YTMT
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
이혜리
2019-11-24 19:35:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b1237c984a175bdf9c075c68e678436b38b7d1d3
b1237c98
1 parent
be728b43
인기순위-여자
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletions
routes/index.js
views/index.ejs
routes/index.js
View file @
b1237c9
...
...
@@ -6,6 +6,7 @@ var mysql = require('mysql');
var
client
=
require
(
'cheerio-httpcli'
);
var
passport
=
require
(
'passport'
),
KakaoStrategy
=
require
(
'passport-kakao'
).
Strategy
;
const
puppeteer
=
require
(
"puppeteer"
);
var
connection
=
mysql
.
createConnection
({
host
:
'localhost'
,
...
...
@@ -283,11 +284,47 @@ function getAllToons() {
allWebtoons
=
allWebtoonList
;
};
popularWWebtoons
=
new
Array
();
function
getPopularToons
()
{
var
pplWebtoonList
=
new
Array
();
puppeteer
.
launch
().
then
(
async
browser
=>
{
let
page
=
await
browser
.
newPage
();
await
page
.
goto
(
"https://comic.naver.com/index.nhn"
,
{
waitUntil
:
"networkidle2"
});
page
.
waitForNavigation
(),
// 해당 페이지의 탐색이 완료되면 클릭 이벤트를 실행
await
page
.
click
(
"#recommandWebtoonRankWTabOver > a"
);
// 클릭이벤트를 실행
let
ehList
=
await
page
.
$$
(
"div.thumb6"
);
for
(
let
eh
of
ehList
)
{
let
webtoon_link
=
await
eh
.
$eval
(
'a'
,
function
(
el
)
{
return
el
.
getAttribute
(
'href'
);
});
let
thumb_link
=
await
eh
.
$eval
(
'a img'
,
function
(
el
)
{
return
el
.
getAttribute
(
'src'
);
});
let
title
=
await
eh
.
$eval
(
'a'
,
function
(
el
)
{
return
el
.
getAttribute
(
'title'
);
});
var
pplObj
=
{
thumb_link
:
thumb_link
,
webtoon_link
:
"http://comic.naver.com"
+
webtoon_link
,
title
:
title
};
pplWebtoonList
.
push
(
pplObj
);
}
browser
.
close
();
popularWWebtoons
=
pplWebtoonList
;
});
}
getAllToons
();
//처음 한번 수행
setInterval
(
getAllToons
,
5
*
60
*
1000
);
//5분에 한번 수행
getPopularToons
();
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
){
...
...
@@ -298,7 +335,8 @@ router.get('/',
console
.
log
(
"(!)로그인세션 없음"
);
res
.
render
(
'index'
,{
title
:
"니툰내툰"
,
list
:
allWebtoons
list
:
allWebtoons
,
pplWList
:
popularWWebtoons
});
}
});
...
...
views/index.ejs
View file @
b1237c9
...
...
@@ -162,6 +162,32 @@
</a>
<div
id=
"Naver_webtoons"
style =
"display:none"
>
</br>
<div
class=
"Pupular"
style=
"border: 1px solid; padding: 12px; width:650px; height:330px; margin:auto;"
>
<table>
<p>
20대 실시간 인기순위
</p>
<tr>
<th
align =
"center"
>
여자
</th>
</tr>
<tr>
<
% let i = 1;
for(toon in pplWList) {
%>
<th>
<
%= i%>
</th>
<th>
<a
href=
"<%= pplWList[toon].webtoon_link %>"
>
<img
alt=
"img"
width=
"43"
height=
"50"
src=
"<%= pplWList[toon].thumb_link %>"
/>
</a>
<
%= pplWList[toon].title %>
</th>
</tr>
<
% i += 1; %>
<
% } %>
</table>
</div>
<a
onclick=
"Naver_webtoons.style.display=(Naver_webtoons.style.display=='none') "
>
<button>
별점순
</button>
</a>
...
...
Please
register
or
login
to post a comment