Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정승우
/
YaguMoa
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
SW0000J
2020-06-09 20:05:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6569e5ae6cb1390811a291082b1b92e6ebf5b341
6569e5ae
1 parent
847e98a8
zum news 크롤링 성공!
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
testcode/test2.js
testcode/test2.js
0 → 100644
View file @
6569e5a
const
axios
=
require
(
"axios"
);
const
cheerio
=
require
(
"cheerio"
);
const
url
=
"https://news.zum.com/issuelist/58654445"
const
getHtml
=
async
()
=>
{
try
{
return
await
axios
.
get
(
url
);
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
getHtml
()
.
then
(
html
=>
{
let
ulList
=
[];
const
$
=
cheerio
.
load
(
html
.
data
);
const
$bodyList
=
$
(
"div.major_news > ul"
).
children
(
"ul.no_reply > li.large"
);
$bodyList
.
each
(
function
(
i
,
elem
)
{
ulList
[
i
]
=
{
url
:
'news.zum.com'
+
$
(
this
).
find
(
'div.img > a'
).
attr
(
'href'
),
image_url
:
$
(
this
).
find
(
'div.img > a > img'
).
attr
(
'src'
),
title
:
$
(
this
).
find
(
'div.txt > div.title > a'
).
text
(),
summary
:
$
(
this
).
find
(
'div.txt > div.content > a'
).
text
(),
//.slice(0, -29)
datetime
:
$
(
this
).
find
(
'div.txt > div.content > span.etc'
).
text
()
};
//console.log(ulList[i]) // list object checking code
});
const
data
=
ulList
.
filter
(
n
=>
n
.
title
);
return
data
;
//return ulList;
}).
then
(
res
=>
console
.
log
(
res
));
\ No newline at end of file
Please
register
or
login
to post a comment