From c1eb974c5bca4521df5c9ec29cc487bb34579858 Mon Sep 17 00:00:00 2001 From: kevinbzhang Date: Fri, 19 Aug 2022 14:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 0da8239..1a94821 100644 --- a/main.js +++ b/main.js @@ -9,7 +9,7 @@ async function getApiResult(url) { method: 'GET', url: url, }, (error, response, result) => { - console.log("error, response, result", error, response, result); + // console.log("error, response, result", error, response, result); if (!error && (response.statusCode == 200)) { // 请求成功 resolve(result); @@ -29,29 +29,31 @@ async function getApiResult(url) { // 目录:https://www.nowcoder.com/content/tutorial/catalog/94 // 文章:https://www.nowcoder.com/content/tutorial/detail/94/ea1986fcff294f6292385703e94689e8 async function main() { + console.log(`获取目录 ${pdfFilePath}`); /** * 爬取数据 */ let urlContent = "https://www.nowcoder.com/content/tutorial/catalog/94"; let result = await getApiResult(urlContent); let data = JSON.parse(result); - console.log(data); + // console.log(data); let catalog = data.data.catalog; - console.log("catalog", catalog); + // console.log("catalog", catalog); for (let chapter = 0; chapter < catalog.length; chapter++) { const sectionList = catalog[chapter]; for (let section = 0; section < sectionList.length; section++) { const sectionInfo = sectionList[section]; // console.log(`${sectionInfo.uuid} ${sectionInfo.title}`); let res = await getDetail(sectionInfo.uuid); - console.log(res); + // console.log(res); } } console.log("完成"); } async function getDetail(uuid) { + console.log(`开始转换 ${pdfFilePath}`); let urlDetail = `https://www.nowcoder.com/content/tutorial/detail/94/${uuid}`; let result = await getApiResult(urlDetail); let data = JSON.parse(result);