mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-18 08:17:01 +00:00
Fix build (#12516)
* Empty commit * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
787aa5d3b5
commit
cfcc84edf7
|
@ -15,7 +15,7 @@ Current ORCL stock price is 188.87
|
|||
def stock_price(symbol: str = "AAPL") -> str:
|
||||
"""
|
||||
>>> stock_price("EEEE")
|
||||
'-'
|
||||
'- '
|
||||
>>> isinstance(float(stock_price("GOOG")),float)
|
||||
True
|
||||
"""
|
||||
|
@ -24,12 +24,10 @@ def stock_price(symbol: str = "AAPL") -> str:
|
|||
url, headers={"USER-AGENT": "Mozilla/5.0"}, timeout=10
|
||||
).text
|
||||
soup = BeautifulSoup(yahoo_finance_source, "html.parser")
|
||||
specific_fin_streamer_tag = soup.find("fin-streamer", {"data-testid": "qsp-price"})
|
||||
|
||||
if specific_fin_streamer_tag:
|
||||
text = specific_fin_streamer_tag.get_text()
|
||||
return text
|
||||
return "No <fin-streamer> tag with the specified data-test attribute found."
|
||||
if specific_fin_streamer_tag := soup.find("span", {"data-testid": "qsp-price"}):
|
||||
return specific_fin_streamer_tag.get_text()
|
||||
return "No <fin-streamer> tag with the specified data-testid attribute found."
|
||||
|
||||
|
||||
# Search for the symbol at https://finance.yahoo.com/lookup
|
||||
|
|
Loading…
Reference in New Issue
Block a user