김대선

KakaoFunction.js 수정 및 puppeteer timeouterror 수정

...@@ -32,24 +32,19 @@ const makeObject = (array)=>{ ...@@ -32,24 +32,19 @@ const makeObject = (array)=>{
32 return result 32 return result
33 } 33 }
34 34
35 -const moveNextPage = async (page)=>{
36 -
37 - await page.click('#mArticle > div > div.paging_list > span > a:nth-child(10) > span > span').catch((error)=>{
38 - })
39 - await page.waitForTimeout(1000)
40 - return await page.content()
41 -}
42 -
43 const getData = async ()=>{ 35 const getData = async ()=>{
44 const browser = await puppeteer.launch(); 36 const browser = await puppeteer.launch();
45 const page = await browser.newPage(); 37 const page = await browser.newPage();
38 + page.setDefaultNavigationTimeout(0)
46 39
47 let result = [] 40 let result = []
48 let temp = "" 41 let temp = ""
49 - 42 + let count = 1
50 await page.goto('https://careers.kakao.com/jobs') 43 await page.goto('https://careers.kakao.com/jobs')
51 - let content = await page.content() 44 + let content = ""
52 while(true){ 45 while(true){
46 + await page.goto(`https://careers.kakao.com/jobs?page=${count}`)
47 + content = await page.content()
53 if(temp == content){ 48 if(temp == content){
54 break; 49 break;
55 } 50 }
...@@ -66,12 +61,12 @@ const getData = async ()=>{ ...@@ -66,12 +61,12 @@ const getData = async ()=>{
66 resArr.pop() 61 resArr.pop()
67 result = result.concat(await makeObject(resArr)) 62 result = result.concat(await makeObject(resArr))
68 temp = content 63 temp = content
69 - content = await moveNextPage(page) 64 + count = count + 1
70 } 65 }
66 + console.log("kakao : ", result.length)
71 return result 67 return result
72 } 68 }
73 69
74 module.exports = { 70 module.exports = {
75 getData : getData 71 getData : getData
76 } 72 }
77 -
......
...@@ -40,6 +40,7 @@ const makeObject = (array)=>{ ...@@ -40,6 +40,7 @@ const makeObject = (array)=>{
40 const getData = async ()=>{ 40 const getData = async ()=>{
41 const browser = await puppeteer.launch(); 41 const browser = await puppeteer.launch();
42 const page = await browser.newPage(); 42 const page = await browser.newPage();
43 + page.setDefaultNavigationTimeout(0)
43 44
44 await page.goto('https://recruit.navercorp.com/naver/job/list/developer') 45 await page.goto('https://recruit.navercorp.com/naver/job/list/developer')
45 let content = await page.content() 46 let content = await page.content()
...@@ -66,6 +67,7 @@ const getData = async ()=>{ ...@@ -66,6 +67,7 @@ const getData = async ()=>{
66 }) 67 })
67 resArr = result.split('</li><li>') 68 resArr = result.split('</li><li>')
68 result = makeObject(resArr) 69 result = makeObject(resArr)
70 + console.log("naver : ", result.length)
69 return result; 71 return result;
70 } 72 }
71 73
......
...@@ -43,7 +43,8 @@ const makeObject = (array)=>{ ...@@ -43,7 +43,8 @@ const makeObject = (array)=>{
43 const getData = async ()=>{ 43 const getData = async ()=>{
44 const browser = await puppeteer.launch(); 44 const browser = await puppeteer.launch();
45 const page = await browser.newPage(); 45 const page = await browser.newPage();
46 - 46 + page.setDefaultNavigationTimeout(0)
47 +
47 let result = [] 48 let result = []
48 let temp = "" 49 let temp = ""
49 let count = 1; 50 let count = 1;
......