.replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') for prepost
This commit is contained in:
parent
0ea3abf9d0
commit
e26f27eb38
@ -253,7 +253,7 @@ def updateStocksPrePost(api_key, logf):
|
|||||||
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
|
||||||
|
|
||||||
prepost = requests.get(prepost_url, headers=headers).json()
|
prepost = requests.get(prepost_url.replace('BRK.A', 'BRK-A').replace('BRK.B', 'BRK-B'), headers=headers).json()
|
||||||
if "'error': {'code'" in str(prepost):
|
if "'error': {'code'" in str(prepost):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -269,7 +269,7 @@ def updateStocksPrePost(api_key, logf):
|
|||||||
crumb = f.read()
|
crumb = f.read()
|
||||||
params = {'crumb': crumb}
|
params = {'crumb': crumb}
|
||||||
|
|
||||||
prepost = session.get(prepost_url.replace('v6','v7'), headers=headers, params=params).json()
|
prepost = session.get(prepost_url.replace('v6','v7').replace('BRK.A', 'BRK-A').replace('BRK.B', 'BRK-B'), headers=headers, params=params).json()
|
||||||
|
|
||||||
if "'error': {'code'" not in str(prepost):
|
if "'error': {'code'" not in str(prepost):
|
||||||
break
|
break
|
||||||
@ -286,24 +286,24 @@ def updateStocksPrePost(api_key, logf):
|
|||||||
if stock['symbol'] == symbol:
|
if stock['symbol'] == symbol:
|
||||||
stock_info[stock['symbol']] = {"time_now":time_now}
|
stock_info[stock['symbol']] = {"time_now":time_now}
|
||||||
try:
|
try:
|
||||||
stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['preMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['preMarketPrice'],
|
||||||
'prechange': '%.2f' % stock['preMarketChange'],
|
'prechange': '%.2f' % stock['preMarketChange'],
|
||||||
'prepercent': '%.2f' % stock['preMarketChangePercent']}
|
'prepercent': '%.2f' % stock['preMarketChangePercent']}
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['postMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['postMarketPrice'],
|
||||||
'prechange': '%.2f' % 0,
|
'prechange': '%.2f' % 0,
|
||||||
'prepercent': '%.2f' % 0}
|
'prepercent': '%.2f' % 0}
|
||||||
except:
|
except:
|
||||||
stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'],
|
||||||
'prechange': '%.2f' % 0,
|
'prechange': '%.2f' % 0,
|
||||||
'prepercent': '%.2f' % 0}
|
'prepercent': '%.2f' % 0}
|
||||||
try:
|
try:
|
||||||
stock_info[stock['symbol']]['Post-market'] = {'postprice': '%.2f' % stock['postMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['postMarketPrice'],
|
||||||
'postchange': '%.2f' % stock['postMarketChange'],
|
'postchange': '%.2f' % stock['postMarketChange'],
|
||||||
'postpercent': '%.2f' % stock['postMarketChangePercent']}
|
'postpercent': '%.2f' % stock['postMarketChangePercent']}
|
||||||
except:
|
except:
|
||||||
stock_info[stock['symbol']]['Post-market'] = {'postprice': '%.2f' % stock['regularMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['regularMarketPrice'],
|
||||||
'postchange': '%.2f' % 0,
|
'postchange': '%.2f' % 0,
|
||||||
'postpercent': '%.2f' % 0}
|
'postpercent': '%.2f' % 0}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user