|
|
@ -2,7 +2,6 @@ import locale
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import operator
|
|
|
|
import operator
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import html2text
|
|
|
|
import html2text
|
|
|
|
|
|
|
|
|
|
|
|
from lottery_data_scraper.schemas import GameSchema
|
|
|
|
from lottery_data_scraper.schemas import GameSchema
|
|
|
@ -12,7 +11,7 @@ from lottery_data_scraper.util import fetch_html
|
|
|
|
# because California only gives prize values and our schema
|
|
|
|
# because California only gives prize values and our schema
|
|
|
|
# expects a string representation of the prize.
|
|
|
|
# expects a string representation of the prize.
|
|
|
|
# https://docs.python.org/3/library/locale.html
|
|
|
|
# https://docs.python.org/3/library/locale.html
|
|
|
|
locale.setlocale(locale.LC_ALL, 'en_US.utf8')
|
|
|
|
locale.setlocale(locale.LC_ALL, "en_US.utf8")
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
h = html2text.HTML2Text()
|
|
|
|
h = html2text.HTML2Text()
|
|
|
@ -20,6 +19,7 @@ h = html2text.HTML2Text()
|
|
|
|
BASE_URL = "https://www.calottery.com"
|
|
|
|
BASE_URL = "https://www.calottery.com"
|
|
|
|
SCRATCHER_URL = "https://www.calottery.com/api/games/scratchers"
|
|
|
|
SCRATCHER_URL = "https://www.calottery.com/api/games/scratchers"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def num_tx_initial(game):
|
|
|
|
def num_tx_initial(game):
|
|
|
|
grand_prize = game["topPrizeTier"]
|
|
|
|
grand_prize = game["topPrizeTier"]
|
|
|
|
return grand_prize["odds"] * grand_prize["totalNumberOfPrizes"]
|
|
|
|
return grand_prize["odds"] * grand_prize["totalNumberOfPrizes"]
|
|
|
@ -35,7 +35,9 @@ def fetch_games():
|
|
|
|
"available": prize_["numberOfPrizesPending"],
|
|
|
|
"available": prize_["numberOfPrizesPending"],
|
|
|
|
"claimed": prize_["numberOfPrizesCashed"],
|
|
|
|
"claimed": prize_["numberOfPrizesCashed"],
|
|
|
|
"value": prize_["value"],
|
|
|
|
"value": prize_["value"],
|
|
|
|
"prize": locale.currency(prize_["value"], grouping=True)[:-3] # -3 to drop the cents
|
|
|
|
"prize": locale.currency(prize_["value"], grouping=True)[
|
|
|
|
|
|
|
|
:-3
|
|
|
|
|
|
|
|
], # -3 to drop the cents
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prizes.append(prize)
|
|
|
|
prizes.append(prize)
|
|
|
|
grand_prize = sorted(game_["prizeTiers"], key=operator.itemgetter("value"))[-1]
|
|
|
|
grand_prize = sorted(game_["prizeTiers"], key=operator.itemgetter("value"))[-1]
|
|
|
|