Commit 51a5f081 authored by baesangjune's avatar baesangjune
Browse files

.

parent 79e5a90c
This diff is collapsed.
......@@ -38,5 +38,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"proxy": "http://localhost:3001"
}
This diff is collapsed.
......@@ -3,19 +3,20 @@
"version": "1.0.0",
"description": "Search Page 2020 Winter",
"main": "index.js",
"type": "module",
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.5.3",
"cheerio": "^1.0.0-rc.5",
"express": "^4.17.1",
"nodemon": "^2.0.6",
"react-bootstrap": "^1.4.0",
"request": "^2.88.2"
},
"devDependencies": {},
"scripts": {
"dev": "nodemon server/server.js",
"dev": "nodemon server/scraper.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
......
......@@ -12,13 +12,22 @@ const app = express()
// body > main > div > section > ul > li > article > h2 > a
// 에 속하는 제목을 titleList에 저장
app.get('/', (req, res) => {
const url = "https://section.blog.naver.com/Search/Post.nhn?pageNo=1&rangeType=ALL&orderBy=sim&keyword=%ED%95%9C%EB%9D%BC%EC%82%B0"
request(url,function(err, res, html) {
console.log(html)
if(!err){
let $=cheerio.load(html);
const url = "https://www.naver.com/"
request(url, function (err, res, html) {
// console.log(html)
if (!err) {
let resultArr = [];
let $ = cheerio.load(html, null, false); // false 넣으면 헤더같은 거 없애고 null은 속성넣어줄 수 있음.
let colArr = $(".list_theme_wrap")//가져올 클래스 넣기
for (let i = 0; i < colArr.length; i++) {
resultArr.push(colArr[i].children[1].attribs.title)
}
console.log(resultArr)
}
}
// .then(html => {
// let titleList = [];
// const $ = cheerio.load(html.data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment