Add exception catch
This commit is contained in:
parent
69ec6d2732
commit
7585453ff0
@ -39,14 +39,18 @@ def get_services(headcode, date):
|
||||
results = []
|
||||
url = OB_TRN_BASE_URL + f"{date.strftime('%Y-%m-%d')}/headcode/{headcode.lower()}"
|
||||
print(url)
|
||||
res = requests.get(url, headers=HEADERS)
|
||||
if res.status_code == 200:
|
||||
json_res = res.json()
|
||||
for item in json_res:
|
||||
if item['operator'] == 'GW':
|
||||
results.append(item)
|
||||
print(f"Found {len(results)} valid GWR Service")
|
||||
return results
|
||||
try:
|
||||
res = requests.get(url, headers=HEADERS)
|
||||
if res.status_code == 200:
|
||||
json_res = res.json()
|
||||
for item in json_res:
|
||||
if item['operator'] == 'GW':
|
||||
results.append(item)
|
||||
print(f"Found {len(results)} valid GWR Service")
|
||||
return results
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit()
|
||||
|
||||
def get_service_detail(trainUid, date):
|
||||
try:
|
||||
|
Reference in New Issue
Block a user