import fs from 'fs' import cheerio from 'cheerio' import fetch from 'node-fetch' import { Data } from '../components/index.js' import lodash from "lodash"; import request from "request"; const _path = process.cwd() const artiIdx = { Flower: 1, Plume: 2, Sands: 3, Goblet: 4, Circlet: 5 } function getEffect (txt) { let regRet = /(\d) Piece:/.exec(txt) if (regRet) { return [regRet[1], txt.replace(regRet[0], '').trim().replace(/。$/, '')] } return [] } async function getSets (id) { const url = `https://genshin.honeyhunterworld.com/i_${id}/?lang=CHS` let req = await fetch(url) let txt = await req.text() let sTxt = /sortable_data.push\((.*)\)/.exec(txt) let ret = {} if (sTxt && sTxt[1]) { let arrs = eval(sTxt[1]) lodash.forEach(arrs, (ds) => { let $ = cheerio.load(ds.join('')) let a = $('a:eq(1)') let idRet = /i_(.+)\//.exec(a.attr('href')) let nRet = /^(\w+)\s/.exec($('a:last').text()) if (nRet && idRet) { ret[artiIdx[nRet[1]]] = { id: idRet[1], name: a.text() } } }) } return ret } async function down () { const url = 'https://genshin.honeyhunterworld.com/fam_art_set/?lang=CHS' let req = await fetch(url) let txt = await req.text() let ret = {} let tmp = {} let sTxt = /sortable_data.push\((.*)\)/.exec(txt) if (sTxt && sTxt[1]) { let tmp = eval(sTxt[1]) lodash.forEach(tmp, (ds) => { let na = cheerio.load(ds[0])('a:last') let idRet = /i_(\w+)\//.exec(na.attr('href')) if (idRet && idRet[1]) { let effect = {} let $ = cheerio.load(`