fixing the stock function, it needs a fake user agent now
This commit is contained in:
parent
c1775f767d
commit
fc73a61173
@ -16,12 +16,15 @@ def parse_message(msg):
|
||||
|
||||
def get_stock(share_name):
|
||||
share_name = share_name.upper()
|
||||
# Fake headers to make yahoo happy
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
|
||||
request_string = "https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&symbols=%s" % share_name
|
||||
request = requests.get(request_string).json()['quoteResponse']['result'][0]
|
||||
request = requests.get(request_string, headers=headers).json()['quoteResponse']['result'][0]
|
||||
|
||||
change_symbol = '+'
|
||||
embed_color = 2067276
|
||||
meme_url = 'https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg'
|
||||
# If stock price has gone down since open, use red and a sad stonk meme
|
||||
if float(request['bid']) < float(request['regularMarketOpen']):
|
||||
change_symbol = '-'
|
||||
embed_color = 15158332
|
||||
|
Loading…
x
Reference in New Issue
Block a user