Abstract
The response dictionaries from scraping functions e.g. get_stadiums
(StadiumsScraper.get
) and get_odds_trifecta
(TrifectaOddsScraper.get
), should contain the arguments: date, stadium number and race number.
AsIs: Background
A use case of pyjpboatrace is to use pyjpboatrace scrapers to create boatrace database, where date, stadium number and race number are likely to be primary keys. However, the response dictionaries from scraping functions don't contain the arguments, so it is required to add the arguments, like date, stadium number and race number, to the response dictionaries after scraping.
The following is an example:
from datetime import date
import json
from pyjpboatrace import PyJPBoatrace
# initialize
boatrace_tools = PyJPBoatrace()
# get data
d=date(2020,12,2)
stadium=1
race=4
response = boatrace_tools.get_odds_trifecta(d=d, stadium=stadium, race=race)
# add date, stadium and race to response
# because response is a dictionary like {"1-2-3": 7.0, ..., "6-5-4": 9999}
response["date"] = d
response["stadium"] = stadium
response["race"] = race
# close (you can use 'with' statement)
boatrace_tools.close()
ToBe: Describe the solution you'd like
I want the response dictionaries from pyjpboatrace's scrapers to contain the arugments like date, stadium number and race number. For example, the reponse from get_odds_trifecta
should be like
{
"date": date(2020, 1, 1), # This is a new element.
"stadium": 1, # This is a new element.
"race": 1, # This is a new element.
"1-2-3": 5.6,
"1-2-4": 14.4,
...,
"6-5-4": 8650.0
}