去除多余输出信息
This commit is contained in:
parent
4def9eed4a
commit
c1eb974c5b
10
main.js
10
main.js
@ -9,7 +9,7 @@ async function getApiResult(url) {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: url,
|
url: url,
|
||||||
}, (error, response, result) => {
|
}, (error, response, result) => {
|
||||||
console.log("error, response, result", error, response, result);
|
// console.log("error, response, result", error, response, result);
|
||||||
if (!error && (response.statusCode == 200)) {
|
if (!error && (response.statusCode == 200)) {
|
||||||
// 请求成功
|
// 请求成功
|
||||||
resolve(result);
|
resolve(result);
|
||||||
@ -29,29 +29,31 @@ async function getApiResult(url) {
|
|||||||
// 目录:https://www.nowcoder.com/content/tutorial/catalog/94
|
// 目录:https://www.nowcoder.com/content/tutorial/catalog/94
|
||||||
// 文章:https://www.nowcoder.com/content/tutorial/detail/94/ea1986fcff294f6292385703e94689e8
|
// 文章:https://www.nowcoder.com/content/tutorial/detail/94/ea1986fcff294f6292385703e94689e8
|
||||||
async function main() {
|
async function main() {
|
||||||
|
console.log(`获取目录 ${pdfFilePath}`);
|
||||||
/**
|
/**
|
||||||
* 爬取数据
|
* 爬取数据
|
||||||
*/
|
*/
|
||||||
let urlContent = "https://www.nowcoder.com/content/tutorial/catalog/94";
|
let urlContent = "https://www.nowcoder.com/content/tutorial/catalog/94";
|
||||||
let result = await getApiResult(urlContent);
|
let result = await getApiResult(urlContent);
|
||||||
let data = JSON.parse(result);
|
let data = JSON.parse(result);
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
|
|
||||||
let catalog = data.data.catalog;
|
let catalog = data.data.catalog;
|
||||||
console.log("catalog", catalog);
|
// console.log("catalog", catalog);
|
||||||
for (let chapter = 0; chapter < catalog.length; chapter++) {
|
for (let chapter = 0; chapter < catalog.length; chapter++) {
|
||||||
const sectionList = catalog[chapter];
|
const sectionList = catalog[chapter];
|
||||||
for (let section = 0; section < sectionList.length; section++) {
|
for (let section = 0; section < sectionList.length; section++) {
|
||||||
const sectionInfo = sectionList[section];
|
const sectionInfo = sectionList[section];
|
||||||
// console.log(`${sectionInfo.uuid} ${sectionInfo.title}`);
|
// console.log(`${sectionInfo.uuid} ${sectionInfo.title}`);
|
||||||
let res = await getDetail(sectionInfo.uuid);
|
let res = await getDetail(sectionInfo.uuid);
|
||||||
console.log(res);
|
// console.log(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("完成");
|
console.log("完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDetail(uuid) {
|
async function getDetail(uuid) {
|
||||||
|
console.log(`开始转换 ${pdfFilePath}`);
|
||||||
let urlDetail = `https://www.nowcoder.com/content/tutorial/detail/94/${uuid}`;
|
let urlDetail = `https://www.nowcoder.com/content/tutorial/detail/94/${uuid}`;
|
||||||
let result = await getApiResult(urlDetail);
|
let result = await getApiResult(urlDetail);
|
||||||
let data = JSON.parse(result);
|
let data = JSON.parse(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user