added v6 rollback in case v7 does down for prepost

This commit is contained in:
Justin 2023-04-25 13:25:35 +08:00 committed by GitHub
parent 0d5faa7473
commit d548c8b8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,6 +160,10 @@ def updateStocksPrePost(api_key, logf):
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
} }
prepost = requests.get(prepost_url, headers=headers) prepost = requests.get(prepost_url, headers=headers)
if 'Unauthorized' in str(prepost.json()):
prepost = requests.get(prepost_url.replace('v7','v6'), headers=headers)
prepost_data = prepost.json()['quoteResponse']['result'] prepost_data = prepost.json()['quoteResponse']['result']
time_now = datetime.now(pytz.timezone('America/New_York')).strftime("%H:%M EST") time_now = datetime.now(pytz.timezone('America/New_York')).strftime("%H:%M EST")