引入定时任务
This commit is contained in:
		@@ -6,6 +6,7 @@ const { dirname } = require('path');
 | 
			
		||||
const path = require('path');
 | 
			
		||||
 | 
			
		||||
const DATA_FOLDER = path.join(dirname(__dirname), process.env.DATA_FOLDER ?? 'data');
 | 
			
		||||
console.log("DATA_FOLDER", DATA_FOLDER);
 | 
			
		||||
 | 
			
		||||
// 请求微博热搜 APi 接口
 | 
			
		||||
async function getApiResult(url) {
 | 
			
		||||
@@ -70,8 +71,6 @@ function saveJSON({ now, fileNameSuffix, object, compress = true, uncompress = t
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function main() {
 | 
			
		||||
    console.log("DATA_FOLDER", DATA_FOLDER);
 | 
			
		||||
 | 
			
		||||
    let requestTimestamp = Date.now();
 | 
			
		||||
    let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString();
 | 
			
		||||
 | 
			
		||||
@@ -79,9 +78,9 @@ async function main() {
 | 
			
		||||
    // console.log("result", result);
 | 
			
		||||
 | 
			
		||||
    if (result.ok != 1) {
 | 
			
		||||
        console.log("请求成功,但服务器处理失败。");
 | 
			
		||||
        console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "请求成功,但服务器处理失败。");
 | 
			
		||||
    } else {
 | 
			
		||||
        console.log("请求成功。");
 | 
			
		||||
        console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "请求成功");
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 保存原始数据
 | 
			
		||||
@@ -188,7 +187,8 @@ async function main() {
 | 
			
		||||
            fileNameSuffix: `final`,
 | 
			
		||||
            object: convert,
 | 
			
		||||
            compress: true,
 | 
			
		||||
            uncompress: true
 | 
			
		||||
            // uncompress: true,
 | 
			
		||||
            uncompress: false,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -230,8 +230,10 @@ async function main() {
 | 
			
		||||
            now: now,
 | 
			
		||||
            fileNameSuffix: `simplify`,
 | 
			
		||||
            object: data,
 | 
			
		||||
            compress: true,
 | 
			
		||||
            uncompress: true
 | 
			
		||||
            // compress: true,
 | 
			
		||||
            // uncompress: true,
 | 
			
		||||
            compress: false,
 | 
			
		||||
            uncompress: false,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user