//导入依赖包
const http = require("http");
const https = require("https");
const path = require("path");
const url = require("url");
const fs = require("fs");
const superagent = require("superagent");
const cheerio = require("cheerio");
var num=58
var requesturl="******"
var requesturl1="*******"
var requesturl2="********"
//定义一个空数组,用来接收数据
var result='';
var isNext=false
var timeDowm=null
var list=[]
function getList(){
https.get(requesturl , (res) => {
var data = ''; //接口数据
res.on('data', (chunk) => {
data += chunk; //拼接数据块
});
res.on('end', function() {
let res = JSON.parse(data); //解析json
// console.log(res.data); //打印json
list=res.data
getInfo(num)
})
})
}
getList()
function getInfo(num){
if(num>=list.length){
console.log("完成了",num)
fs.writeFile("******.txt",result,"utf-8",(error)=>{
console.log("文件写入完成")
});
return
}
https.get(requesturl1+list[num].chapterId+ requesturl2, (res) => {
console.log(requesturl1+list[num].****)
var data = ''; //接口数据
res.on('data', (chunk) => {
data += chunk; //拼接数据块
});
res.on('end', function() {
let res = JSON.parse(data); //解析json
let text=res.data.name + res.data.content[0].text
// console.log(text)
result+=text
num++
getInfo(num)
})
})
}