1
0
Code Pull Requests Projects Releases Activity GitHub Gitee

去除多余输出信息

This commit is contained in:
kevinbzhang 2022-08-19 14:19:07 +08:00
parent 4def9eed4a
commit c1eb974c5b

10
main.js
View File

@ -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);