普通人怎么挣到500万?

792 阅读1分钟

注意,本文是瞎扯淡的,仅供娱乐!!!

之前逛知乎的时候发现了这么一个问题

image.png

然后回家去快递的时候,菜鸟驿站正好就是个彩票站,于是就买了张机选5注的体彩大乐透。结果自然是没中。然后就想查一下最近的期数每个位置出现频率最高的数字。

先直接说结果

image.png

数据来源是中国体彩网 历史开奖栏目 (lottery.gov.cn)

直接贴代码,简单的数据处理

const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));


async function getData(num) {
    const res = await fetch(`https://webapi.sporttery.cn/gateway/lottery/getHistoryPageListV1.qry?gameNo=85&provinceId=0&pageSize=${num}&isVerify=1&pageNo=1&termLimits=${num}`, {
        "headers": {
            "accept": "application/json, text/javascript, */*; q=0.01",
            "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
            "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Microsoft Edge\";v=\"101\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "\"Windows\"",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-site",
            "Referer": "https://static.sporttery.cn/",
            "Referrer-Policy": "strict-origin-when-cross-origin"
        },
        "body": null,
        "method": "GET"
    })
    const { value: { list } } = await res.json();


    const initArray = list.map(v => v.lotteryDrawResult.split(' '))

    const newSet = initArray.reduce((pre, cur) => {
        cur.forEach((v, i) => {
            pre[i].push(v)
        })
        return pre
    }, Array(7).fill('').map(() => []))



    const result = newSet.reduce((pre, cur, i) => {
        const setTemp = new Map();
        cur.forEach(v => {
            if (setTemp.has(v)) {
                setTemp.set(v, setTemp.get(v) + 1)
            } else setTemp.set(v, 1);
        })
        pre.push(setTemp)
        return pre
    }, [])

    const finalResult = result.map(v => {
        const arr = Array.from(v)
        const maxIndexObj = arr.reduce((pre, cur) => {
            if (!pre) {
                pre = [0, 0]
            }
            if (cur[1] > pre[1]) {
                return cur
            }
            return pre
        })
        return maxIndexObj[0]
    })
    console.log(`最近${num}次`,finalResult)

    return [finalResult, result]

}


getData(1000)
getData(500)
getData(100)
getData(50)
getData(10)

执行的话需要安装node-fetch

yarn  add  node-fetch