fix stock
This commit is contained in:
parent
1c15af7f5a
commit
73aeb78b8d
@ -12,8 +12,6 @@ wiki_url = "https://starcitizen.tools/"
|
||||
|
||||
|
||||
async def get_ship(ship_name):
|
||||
base_url = "https://robertspaceindustries.com"
|
||||
|
||||
try:
|
||||
wiki_ship_name = "_".join(elem for elem in ship_name.split())
|
||||
|
||||
|
19
app/stock.py
19
app/stock.py
@ -1,6 +1,7 @@
|
||||
import discord
|
||||
import requests
|
||||
import yfinance as yf
|
||||
import os
|
||||
|
||||
|
||||
def parse_message(symbols, verbose):
|
||||
@ -86,22 +87,12 @@ def _add_verbose_fields(embed, request):
|
||||
|
||||
def get_stock(share_name, verbose=False):
|
||||
share_name = share_name.upper()
|
||||
# Fake headers to make yahoo happy
|
||||
# headers = {
|
||||
# "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
|
||||
# }
|
||||
# request_string = (
|
||||
# "https://query2.finance.yahoo.com/v11/finance/quoteSummary/%s?modules=price"
|
||||
# % share_name
|
||||
# )
|
||||
# response = requests.get(request_string, headers=headers).json()["quoteSummary"][
|
||||
# "result"
|
||||
# ]
|
||||
|
||||
# if not response:
|
||||
# raise ValueError("Invalid symbol %s: empty response from Yahoo" % share_name)
|
||||
try:
|
||||
os.mkdir("/root/.cache/py-yfinance")
|
||||
except OSError as error:
|
||||
pass
|
||||
|
||||
# request = response[0]["price"]
|
||||
try:
|
||||
request = yf.Ticker(share_name).info
|
||||
except requests.exceptions.HTTPError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user