김대선

데이터 추출 및 분류 완료

...@@ -6,15 +6,36 @@ const cheerio = require('cheerio') ...@@ -6,15 +6,36 @@ const cheerio = require('cheerio')
6 const sanitizeHtml =require('sanitize-html') 6 const sanitizeHtml =require('sanitize-html')
7 7
8 const splitData = (string)=>{ 8 const splitData = (string)=>{
9 - return string.replace(/(<([^>]+)>)*(\\t)?/gi, "").split("\t").filter((ele)=> ele != '') 9 + const temp = /(<a([^>]+)>)/g.exec(string)
10 + const temp2 = temp[0].split('"');
11 + url = "https://recruit.navercorp.com" + temp2[1];
12 + result = string.replace(/(<([^>]+)>)*(\\t)?/gi, "").split("\t").filter((ele)=> ele != '')
13 + result.pop()
14 + result.push(url)
15 + return result;
10 } 16 }
11 17
12 const makeObject = (array)=>{ 18 const makeObject = (array)=>{
13 - const result = []; 19 + const result = []
20 + let tempData = null
14 for(let i of array){ 21 for(let i of array){
15 - result.push(splitData(i)) 22 + tempData = splitData(i)
23 + if(tempData.length == 5){
24 + result.push({
25 + title : tempData[0],
26 + term : tempData[2],
27 + tags : tempData[3].split('#').filter((ele)=>ele != ''),
28 + url : tempData[4]
29 + })
30 + }
31 + else if (tempData.length == 4){
32 + result.push({
33 + title : tempData[0],
34 + term : tempData[2],
35 + url : tempData[3]
36 + })
37 + }
16 } 38 }
17 -
18 return result 39 return result
19 } 40 }
20 41
......
1 +const splitData = (string)=>{
2 + const temp = /(<a([^>]+)>)/g.exec(string)
3 + console.log(temp)
4 + const temp2 = temp[0].split('"');
5 + console.log(temp2)
6 + url = "https://recruit.navercorp.com" + temp2[1];
7 + console.log(url)
8 + result = string.replace(/(<([^>]+)>)*(\\t)?/gi, "").split("\t").filter((ele)=> ele != '')
9 + result.pop()
10 + result.push(url)
11 + return result;
12 +}
13 +
14 +const string = `\t<a href="/naver/job/detail/developer?annoId=20002849&amp;classId=&amp;jobId=&amp;entTypeCd=&amp;searchTxt=&amp;searchSysComCd=">\t\t<span>\t\t\t<strong>[Platform Engineering] Server Engineer</strong>\t\t\t<span>NEW</span>\t\t\t<em>2021.04.26~2021.05.10</em>\t\t\t<span></span>\t\t</span>\t</a>\t<span><a href="/naver/job/list/developer?entTypeCd=&amp;searchSysComCd=&amp;searchTxt=Platform%20Engineering">#Platform Engineering</a><a href="/naver/job/list/developer?entTypeCd=&amp;searchSysComCd=&amp;searchTxt=Software%20Development">#Software Development</a><a href="/naver/job/list/developer?entTypeCd=&amp;searchSysComCd=&amp;searchTxt=Server">#Server</a><a href="/naver/job/list/developer?entTypeCd=&amp;searchSysComCd=&amp;searchTxt=%EA%B2%BD%EB%A0%A5">#경력</a><a href="/naver/job/list/developer?entTypeCd=&amp;searchSysComCd=&amp;searchTxt=Backend">#Backend</a>\t </span>`
15 +
16 +console.log(splitData(string))
...\ No newline at end of file ...\ No newline at end of file