switched to the new wvlottery.com results api, added cash pop

This commit is contained in:
2026-09-26 02:29:40 -04:00
parent 1037813a3f
commit 01ed0d194b
11 changed files with 176 additions and 48 deletions
+17 -9
View File
@@ -3,7 +3,6 @@ from fractions import Fraction as frac
import pandas as pd
import requests
from collections import Counter
from io import StringIO
def get_data():
@@ -11,19 +10,28 @@ def get_data():
df_old = pd.read_excel('./excel_lotto_records/lotto_megamil.xlsx')
salvaged = df_old[['Date', 'Numbers', 'MB']]
url = 'https://wvlottery.com/draw-games/mega-millions/?game-analyze=mega-millions&what-to-search=historysearch&date-range=-1'
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=20&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
# Get web data
r = requests.get(url, headers=header)
dfs = list(pd.read_html(StringIO(r.text)))
# Get web data, the new site pulls past draws from json 500 at a time
web = {'Date': [], 'Numbers': [], 'MB': []}
page = 0
while True:
r = requests.get(url + str(page), headers=header)
data = r.json()
for x in data['content']:
web['Date'].append(x['drawingDate'])
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
web['MB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
if data['last']:
break
page += 1
dfs = [pd.DataFrame(web)]
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True)
df2 = df[['Date', 'Numbers', 'MB', 'MP']]
df2 = df[['Date', 'Numbers', 'MB']]
date = list(df2['Date'])
nums = list(df2['Numbers'].astype('str'))
MBs = list(df2['MB'].astype('int'))
@@ -50,7 +58,7 @@ for n in range(0, 25):
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency + frequency_mb)
Chance = frac(total_freq, 302575350) # Chance = number call freq / all possible numbers i.e. 11238513
Chance = frac(total_freq, 290472336) # Chance = number call freq / all possible numbers i.e. 290472336
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} MB: {MB}\n"