Keep a growing record of every draw in the excel sheets
- records.py: merge new draws into each sheet instead of replacing it, so history older than what the WV lottery site keeps is not lost. Cash Pop rows are matched by draw id (several draws a day share Date+Numbers). - All scrapers use records.draw_day() for the draw date and merge_save() for the sheet; cash pop now keeps its own cash_pop.xlsx. - Sheets updated with the latest draws, including the backfilled 10/10 Powerball and Lotto America draws. - Ignore __pycache__, cron logs, sheet lock files and server-side backups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f52dd964ad
commit
a8698c88d3
16 files changed
+153
-13
No files matched your search
+7
-1
@@ -1,6 +1,7 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
import pandas as pd
|
||||
import records
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
@@ -12,17 +13,22 @@ def get_data():
|
||||
}
|
||||
# Get web data, cash pop draws every 15 min so only use the last ~3000 draws (about a month)
|
||||
web = {'Date': [], 'Numbers': []}
|
||||
ids, times = [], []
|
||||
page = 0
|
||||
while page < 6:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Date'].append(records.draw_day(x))
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
ids.append(x['externalId'])
|
||||
times.append(x['drawDate'])
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
df2 = pd.DataFrame(web)
|
||||
# The site only keeps a year of cash pop draws, keep our own record of every draw
|
||||
records.merge_save('./excel_lotto_records/cash_pop.xlsx', df2, ids=ids, times=times)
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
return date, nums
|
||||
|
||||
Reference in new issue
Block a user