|
不想动【表1】的话,代码修改如下:
- async function 股票人气榜(){
- async function getRes(argm1, gpdm){
- let p = await fetch(`https://emappdata.eastmoney.com/stockrank/${argm1}`, {
- method: 'POST',
- headers: {'content-type': 'application/json'},
- body: JSON.stringify({'srcSecurityCode': `${gpdm}`})
- });
- let res = await p.json();
- return res;
- };
- const gpdms = [];
- Range('表1[代码]').Value2.flat().some((x, i) => {
- if (!x) return !x;
- if (typeof x == 'number') x = String(x);
- if (x.length < 6) x = '0'.repeat(6 - x.length) + x;
- x = '03'.includes(x[0]) ? 'SZ' + x : 'SH' + x;
- gpdms.push(x);
- });
- if (!gpdms) return;
- Range('表1[代码]').Resize(gpdms.length, 1).Value2 = gpdms.map(x =>
- [`=HYPERLINK("http://guba.eastmoney.com/rank/stock?code=${x.slice(2)}", "${x.slice(2)}")`])
- let res1 = await Promise.all(gpdms.map((x, i) => getRes('getCurrentLatest', x)));
- let res2 = await Promise.all(gpdms.map((x, i) => getRes('getProfileStockRank', x)));
- let res = res1.map((x, i) =>
- [x.data.rank, x.data.rankChange, res2[i].data.oldUidRate, res2[i].data.newUidRate]
- );
- Range('表1[[实时排名]:[铁杆粉丝]]').Resize(res.length, res[0].length).Value2 = res;
- }
复制代码 |
评分
-
1
查看全部评分
-
|