Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2019-1-OpenSourceSW
/
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
강현태
2017-12-02 22:12:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f6cf4a19d61ea6ee5a3e48a7274778c08b45390a
f6cf4a19
1 parent
d304e645
getAllToons()추가 index에 모든 웹툰 출력
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
8 deletions
.idea/workspace.xml
app.js
routes/index.js
views/index.ejs
.idea/workspace.xml
View file @
f6cf4a1
This diff is collapsed. Click to expand it.
app.js
View file @
f6cf4a1
...
...
@@ -61,7 +61,6 @@ function getUpdatedToons(){
var
toonName
=
link
.
text
();
var
toonHref
=
link
.
attr
(
'href'
);
console
.
log
(
toonName
+
' -> '
+
toonHref
);
updatedToon
[
toonName
]
=
toonHref
;
});
...
...
@@ -69,5 +68,33 @@ function getUpdatedToons(){
});
}
allWebtoons
=
getAllToons
();
function
getAllToons
()
{
var
allWeeklyToonsUrl
=
"http://comic.naver.com/webtoon/weekday.nhn"
;
allWebtoonJSONList
=
new
Array
();
request
(
allWeeklyToonsUrl
,
function
(
err
,
res
,
html
)
{
if
(
!
err
){
var
$
=
cheerio
.
load
(
html
);
$
(
".thumb"
).
each
(
function
(
i
)
{
var
week
=
$
(
this
).
parent
().
parent
().
prev
().
attr
(
'class'
);
var
webtoon_link
=
"http://comic.naver.com"
+
$
(
this
).
children
().
first
().
attr
(
'href'
);
var
thumb_link
=
$
(
this
).
children
().
first
().
children
().
first
().
attr
(
'src'
);
var
name
=
$
(
this
).
next
().
text
();
var
webtoon
=
{
name
:
name
,
thum_link
:
thumb_link
,
webtoon_link
:
webtoon_link
,
week
:
week
};
webtoon_string
=
JSON
.
stringify
(
webtoon
);
//JSON으로 만든당.
allWebtoonJSONList
.
push
(
webtoon_string
);
})
}
});
return
(
allWebtoonJSONList
);
}
module
.
exports
=
app
;
\ No newline at end of file
...
...
routes/index.js
View file @
f6cf4a1
...
...
@@ -6,7 +6,7 @@ router.get('/', function(req, res, next) {
res
.
render
(
'index'
,
{
title
:
'니툰내툰'
,
list
:
updatedToon
list
:
allWebtoons
});
});
...
...
views/index.ejs
View file @
f6cf4a1
...
...
@@ -4,17 +4,40 @@
<title>
<
%= title %>
</title>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
</head>
<body>
<h1>
<
%= title %>
</h1>
<p>
<
%= title %>
</p>
<table>
<
%
for(name in list){
%>
<
%= name+ "=" + list[name] %>
</br>
var current = "";
for(jsonString in list){
var A=JSON.parse(list[jsonString]);
if(current!=A.week){
if(current!=""){
%>
</tr>
<
% } %>
<tr>
<th>
<
%= A.week %>
</th>
<
% } %>
<td>
<a
href=
"<%= A.webtoon_link %>"
>
<img
src=
"<%= A.thum_link %>"
/>
</a>
<
%= A.name %>
</td>
<
%
if(current!=A.week) {
current = A.week;
%>
<
%
}
}
%>
<br>
</tr>
</table>
</br>
</body>
</html>
...
...
Please
register
or
login
to post a comment