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-12-05 16:09:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d15b71f3dfe95aa448548e0b4fa89db756a26a1
8d15b71f
1 parent
eb08afde
파일분리!
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
460 additions
and
0 deletions
routes/index3.js
routes/index3.js
0 → 100644
View file @
8d15b71
var
express
=
require
(
'express'
);
var
cheerio
=
require
(
'cheerio'
);
var
request
=
require
(
'request'
);
const
axios
=
require
(
'axios'
);
//axios 추가 설치된거 확인하기
var
router
=
express
.
Router
();
var
mysql
=
require
(
'mysql'
);
var
client
=
require
(
'cheerio-httpcli'
);
var
passport
=
require
(
'passport'
),
KakaoStrategy
=
require
(
'passport-kakao'
).
Strategy
;
passport
.
use
(
new
KakaoStrategy
({
clientID
:
'bd2e610396fb7bbb84cf91a786b3cc72'
,
callbackURL
:
'/auth/login/kakao/callback'
,
clientSecret
:
'eUtJGtlLoCZJufevp3LKfDP0KOtZUV7R'
},
function
(
accessToken
,
refreshToken
,
params
,
profile
,
done
){
//사용자 정보는 profile에
loginByThirdparty
(
accessToken
,
refreshToken
,
profile
);
console
.
log
(
"(!)로그인 : "
+
profile
.
_json
.
id
+
"("
+
profile
.
_json
.
properties
.
nickname
+
")"
);
//return done(null,profile)
return
done
(
null
,
{
'user_id'
:
profile
.
_json
.
id
,
'nickname'
:
profile
.
_json
.
properties
.
nickname
});
}
));
// kakao 로그인
router
.
get
(
'/auth/login/kakao'
,
// passport.authenticate('kakao',{state: "myStateValue"})
passport
.
authenticate
(
'kakao'
)
);
// kakao 로그인 연동 콜백
router
.
get
(
'/auth/login/kakao/callback'
,
passport
.
authenticate
(
'kakao'
,
{
//session: false,
successRedirect
:
'/mytoons'
,
failureRedirect
:
'/'
})
);
function
loginByThirdparty
(
accessToken
,
refreshToken
,
profile
)
{
//예전 코드는 MySQL 버젼이 맞지 않음
// var sql = 'INSERT INTO `user`(id) VALUES(?) ON DUPLICATE KEY(PRIMARY) UPDATE id=(?);'
var
sql
=
"INSERT INTO `user` (id) VALUES (?) ON DUPLICATE KEY UPDATE id=id"
;
var
kid
=
[
profile
.
_json
.
id
];
connection
.
query
(
sql
,
kid
,
function
(
err
,
result
){
if
(
err
)
{
console
.
log
(
"로그인 쿼리중 에러 : "
+
err
);
}
else
{
console
.
log
(
"로그인 DB처리 완료!"
);
}
});
}
router
.
get
(
'/auth/logout/kakao'
,
function
(
req
,
res
)
{
req
.
logout
();
res
.
redirect
(
'/'
);
})
//---------------------------------------------------------------------------------------------------------------------
allWebtoons3
=
new
Array
();
function
getAllToons3
(){
allWebtoonList3
=
new
Array
();
//2019년 연재 네이버 웹툰
const
naver2019
=
'https://comic.naver.com/webtoon/period.nhn?period=2019'
;
axios
.
get
(
naver2019
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2019
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2019
;
$toonList
.
each
(
function
(
i
)
{
naver2019
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2019
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2018년 연재 네이버 웹툰
const
naver2018
=
'https://comic.naver.com/webtoon/period.nhn?period=2018'
;
axios
.
get
(
naver2018
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2018
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2018
;
$toonList
.
each
(
function
(
i
)
{
naver2018
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2018
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2017년 연재 네이버 웹툰
const
naver2017
=
'https://comic.naver.com/webtoon/period.nhn?period=2017'
;
axios
.
get
(
naver2017
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2017
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2017
;
$toonList
.
each
(
function
(
i
)
{
naver2017
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2017
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2016년 연재 네이버 웹툰
const
naver2016
=
'https://comic.naver.com/webtoon/period.nhn?period=2016'
;
axios
.
get
(
naver2016
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2016
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2016
;
$toonList
.
each
(
function
(
i
)
{
naver2016
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2016
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2015년 연재 네이버 웹툰
const
naver2015
=
'https://comic.naver.com/webtoon/period.nhn?period=2015'
;
axios
.
get
(
naver2015
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2015
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2015
;
$toonList
.
each
(
function
(
i
)
{
naver2015
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2015
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2014년 연재 네이버 웹툰
const
naver2014
=
'https://comic.naver.com/webtoon/period.nhn?period=2014'
;
axios
.
get
(
naver2014
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2014
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2014
;
$toonList
.
each
(
function
(
i
)
{
naver2014
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2014
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2013년 연재 네이버 웹툰
const
naver2013
=
'https://comic.naver.com/webtoon/period.nhn?period=2013'
;
axios
.
get
(
naver2013
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2013
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2013
;
$toonList
.
each
(
function
(
i
)
{
naver2013
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2013
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2012년 연재 네이버 웹툰
const
naver2012
=
'https://comic.naver.com/webtoon/period.nhn?period=2012'
;
axios
.
get
(
naver2012
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2012
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2012
;
$toonList
.
each
(
function
(
i
)
{
naver2012
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2012
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2011년 연재 네이버 웹툰
const
naver2011
=
'https://comic.naver.com/webtoon/period.nhn?period=2011'
;
axios
.
get
(
naver2011
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2011
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2011
;
$toonList
.
each
(
function
(
i
)
{
naver2011
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2011
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2010년 연재 네이버 웹툰
const
naver2010
=
'https://comic.naver.com/webtoon/period.nhn?period=2010'
;
axios
.
get
(
naver2010
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2010
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2010
;
$toonList
.
each
(
function
(
i
)
{
naver2010
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2010
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2009년 연재 네이버 웹툰
const
naver2009
=
'https://comic.naver.com/webtoon/period.nhn?period=2009'
;
axios
.
get
(
naver2009
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2009
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2009
;
$toonList
.
each
(
function
(
i
)
{
naver2009
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2009
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2008년 연재 네이버 웹툰
const
naver2008
=
'https://comic.naver.com/webtoon/period.nhn?period=2008'
;
axios
.
get
(
naver2008
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2008
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2008
;
$toonList
.
each
(
function
(
i
)
{
naver2008
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2008
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2007년 연재 네이버 웹툰
const
naver2007
=
'https://comic.naver.com/webtoon/period.nhn?period=2007'
;
axios
.
get
(
naver2007
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2007
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2007
;
$toonList
.
each
(
function
(
i
)
{
naver2007
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2007
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2006년 연재 네이버 웹툰
const
naver2006
=
'https://comic.naver.com/webtoon/period.nhn?period=2006'
;
axios
.
get
(
naver2006
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2006
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2006
;
$toonList
.
each
(
function
(
i
)
{
naver2006
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2006
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
//2005년 연재 네이버 웹툰
const
naver2005
=
'https://comic.naver.com/webtoon/period.nhn?period=2005'
;
axios
.
get
(
naver2005
).
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
let
naver2005
=
[];
const
$
=
cheerio
.
load
(
res
.
data
);
const
$toonList
=
$
(
'#content > div.list_area.daily_img > ul > li'
);
var
tn
=
2005
;
$toonList
.
each
(
function
(
i
)
{
naver2005
[
i
]
=
{
title
:
$
(
this
).
find
(
'dl > dt > a'
).
text
(),
img
:
$
(
this
).
find
(
'div > a > img'
).
attr
(
'src'
),
index
:
$
(
this
).
find
(
'li > div > a'
).
attr
(
'href'
),
year
:
tn
};
});
const
data
=
naver2005
.
filter
(
m
=>
m
.
title
);
allWebtoonList3
.
push
(
data
);
//console.log(allWebtoonList3)
}
},
(
error
)
=>
console
.
log
(
error
));
allWebtoons3
=
allWebtoonList3
;
}
getAllToons3
();
setInterval
(
getAllToons3
,
5
*
60
*
1000
);
/* GET home page. */
//진아 : list :allWebtoons2.3 해도 되는지??!!
router
.
get
(
'/'
,
function
(
req
,
res
,
next
){
if
(
req
.
isAuthenticated
()){
res
.
redirect
(
'/mytoons'
);
console
.
log
(
"(!)이미 로그인"
);
}
else
{
console
.
log
(
"(!)로그인세션 없음"
);
res
.
render
(
'index'
,{
title
:
"니툰내툰"
,
list
:
allWebtoons3
});
}
});
module
.
exports
=
router
;
Please
register
or
login
to post a comment