|
|
@@ -7,7 +7,6 @@ import collections
|
|
|
# import pytz
|
|
|
from pprint import pprint
|
|
|
|
|
|
-
|
|
|
"""
|
|
|
This module contains custom methods based on bs4.beautifulsoup to analyze data
|
|
|
"""
|
|
|
@@ -66,8 +65,9 @@ def get_today_row(this_text, this_row):
|
|
|
# Create the Scratchings URL by substitution
|
|
|
scratchings_url = re.sub(r"/(.*)\.aspx", 'Scratchings.aspx', this_url)
|
|
|
scratchings_url = base_url + scratchings_url
|
|
|
+ calculated_date = model.convert_to_date(date_string)
|
|
|
this_race_day = RaceDayShort(this_venue.state, this_venue.name, date_string,
|
|
|
- '1970-01-01', scratchings_url)
|
|
|
+ calculated_date.strftime('%Y-%m-%d'), scratchings_url)
|
|
|
all_race_days.append(this_race_day)
|
|
|
i += 1
|
|
|
return all_race_days
|
|
|
@@ -83,6 +83,7 @@ def get_meta_data(this_data, this_venue):
|
|
|
:param this_venue:
|
|
|
:return:
|
|
|
"""
|
|
|
+ global print_it
|
|
|
this_soup = BeautifulSoup(this_data, 'html.parser')
|
|
|
early = this_soup.select('div.large')
|
|
|
# if early:
|
|
|
@@ -114,10 +115,11 @@ def get_meta_data(this_data, this_venue):
|
|
|
# print(times[1])
|
|
|
match = close_regex.search(this_meta_data)
|
|
|
utctime = datetime.datetime.utcnow()
|
|
|
- if (utctime.hour in [15,16,17,18] and utctime.minute > 49) or \
|
|
|
- (utctime.hour in [16,17,18,19] and utctime.minute < 11):
|
|
|
+ if (utctime.hour in (15, 16, 17, 18) and utctime.minute > 49) or \
|
|
|
+ (utctime.hour in (16, 17, 18, 19) and utctime.minute < 11):
|
|
|
print_it = True
|
|
|
print('utctime: {}'.format(utctime))
|
|
|
+
|
|
|
if match:
|
|
|
print_it = False
|
|
|
if '-19 ' not in match.group(1):
|
|
|
@@ -139,14 +141,14 @@ def get_meta_data(this_data, this_venue):
|
|
|
if print_it or times[3] < 1e6:
|
|
|
print_it = True
|
|
|
print('datetime.date.fromtimestamp(times[3]+12*60*60): {}'.format(
|
|
|
- datetime.date.fromtimestamp(times[3]+12*60*60)))
|
|
|
+ datetime.date.fromtimestamp(times[3] + 12 * 60 * 60)))
|
|
|
elif print_it:
|
|
|
print('this_meta_data: {}'.format(this_meta_data))
|
|
|
print('No match for regex: {}'.format(close_regex))
|
|
|
pprint(times)
|
|
|
# The RaceDAy namedTuple is created and filled
|
|
|
race_day = RaceDay(this_venue.state, this_venue.name, this_venue.date_string,
|
|
|
- datetime.date.fromtimestamp(times[3]+12*60*60),
|
|
|
+ datetime.date.fromtimestamp(times[3] + 12 * 60 * 60),
|
|
|
this_venue.scratchings_url, times[0], times[1], times[2], times[3])
|
|
|
return race_day
|
|
|
|