const send_request = require('./utils/send_request'); const fs = require('fs'); const path = require('path'); // 2024.06.25 function getList() { // https://api.xiaobot.net/paper/oneCompany/post?limit=20&offset=0&tag_name=&keyword=&order_by=created_at+undefined const url = 'https://api.xiaobot.net/paper/oneCompany/post' const data = { limit: 200, offset: 0, tag_name: '', keyword: '', order_by: "created_at " + undefined, } send_request.call('GET', url, data, (e) => { const response = e.data const data = response.data // console.log('data', data) console.log('data', data.length, data.map(d => JSON.stringify(d).substring(0, 100))) const uuidTitleMap = {} for (const item of data) { uuidTitleMap[item.uuid] = item.title } for (const item of data) { let contentHtml = item.content for (const uuid in uuidTitleMap) { // https://xiaobot.net/post/83e3da77-0c09-4ecb-a8dd-3d7e5d191a6d contentHtml = contentHtml.replace('https://xiaobot.net/post/' + uuid, './' + uuidTitleMap[uuid] + '.html') } const html =` ${item.title}
${contentHtml}
` fs.writeFileSync(path.join(__dirname, 'output', item.title + '.json'), JSON.stringify(item, null, 4), 'utf-8') fs.writeFileSync(path.join(__dirname, 'output', item.title + '.html'), html, 'utf-8') } }) } getList()