송용우

Merge branch 'feature/crawling' into develop

This diff could not be displayed because it is too large.
......@@ -4,17 +4,21 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"axios": "^0.19.2",
"bcrypt": "^4.0.1",
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.3",
"dotenv": "^8.2.0",
"eslint-config-prettier": "^6.11.0",
"express": "^4.17.1",
"fs": "^0.0.1-security",
"iconv": "^3.0.0",
"joi": "^14.3.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.17",
"morgan": "^1.10.0",
"path": "^0.12.7"
"path": "^0.12.7",
"voca": "^1.4.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
......
const axios = require("axios");
const cheerio = require("cheerio");
let userid_test = "syw5141";
const getHtml = async (userid) => {
try {
return await axios.get("https://www.acmicpc.net/user/" + userid);
} catch (error) {
console.log(error);
}
};
getHtml(userid_test).then((html) => {
let psList = [];
const $ = cheerio.load(html.data);
const $bodyList = $("div.panel-body").children();
$bodyList.each(function (i) {
if (i % 2 == 0) {
psList[i / 2] = {
problem_number: $(this).children().text(),
problem_title: $(this).next().children().text(),
};
}
});
console.log(psList);
return psList;
});
//body > div.wrapper > div.container.content > div.row > div:nth-child(2) > div:nth-child(3) > div.col-md-9 > div:nth-child(1) > div.panel-body