import fs from 'fs' import cheerio from 'cheerio' import fetch from 'node-fetch' import { Data } from '#miao' import lodash from 'lodash' import request from 'request' import HttpsProxyAgent from 'https-proxy-agent' let agent = new HttpsProxyAgent('http://localhost:4780') const artiIdx = { Flower: 1, Plume: 2, Sands: 3, Goblet: 4, Circlet: 5 } async function getSets (id) { const url = `https://genshin.honeyhunterworld.com/i_${id}/?lang=CHS` let req = await fetch(url, { agent }) let txt = await req.text() let sTxt = /sortable_data.push\((.*)\)/.exec(txt) let ret = {} if (sTxt && sTxt[1]) { // eslint-disable-next-line no-eval 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 (sets = '') { const url = 'https://genshin.honeyhunterworld.com/fam_art_set/?lang=CHS' let req = await fetch(url, { agent }) let txt = await req.text() if (sets) { sets = sets.split(',') } let ret = {} let sTxt = /sortable_data.push\((.*)\)/.exec(txt) if (sTxt && sTxt[1]) { // eslint-disable-next-line no-eval let txt = sTxt[1] txt = txt.replace(/