1 Star 0 Fork 2

阿念/lolmvp

forked from ZaraNengap/lolmvp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
getBattleData.js 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
ZaraNengap 提交于 2023-07-16 00:19 . feat: merge cherrypick
const request = require('request-promise');
const getHeaders = require('./getHeaders');
const headers = getHeaders();
const common = {
jar: true,
method: 'POST',
gzip: true,
headers,
};
const LIST_URL = 'https://www.wegame.com.cn/api/v1/wegame.pallas.game.LolBattle/GetBattleList';
const DETAIL_URL = 'https://www.wegame.com.cn/api/v1/wegame.pallas.game.LolBattle/GetBattleDetail';
module.exports = async ({ qq, id, count, area }) => {
const listRes = await Promise.all(
Array.from({ length: Math.ceil(count / 10 ) }).map((_i, index) => request({
...common,
url: LIST_URL,
body: JSON.stringify({
account_type: 1,
area,
id: qq,
count: index === Math.ceil(count / 10) - 1 ? (count === 10 ? count : count % 10) : 10,
filter: '',
offset: index * 10,
from_src: 'lol_helper'
}),
})),
)
const listResult = {
battles: [],
};
listRes.forEach(item => listResult.battles.push(...(JSON.parse(item).battles)));
let result = {};
const battles = listResult?.battles || [];
result.list = battles;
await Promise.all(battles.map(item => {
return request({
...common,
url: DETAIL_URL,
body: JSON.stringify({
account_type: 2,
area,
id,
game_id: item.game_id,
from_src: 'lol_helper',
}),
}).then(res => {
const detailResult = JSON.parse(res);
result.list.find(i => i.game_id === item.game_id).battle_detail = detailResult.battle_detail;
});
}));
return result;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lizhongnian/lolmvp.git
[email protected]:lizhongnian/lolmvp.git
lizhongnian
lolmvp
lolmvp
master

搜索帮助