Skip to content

Fix build #12516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions web_programming/current_stock_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def stock_price(symbol: str = "AAPL") -> str:
"""
>>> stock_price("EEEE")
'-'
'- '
>>> isinstance(float(stock_price("GOOG")),float)
True
"""
Expand All @@ -24,12 +24,11 @@ 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:
if specific_fin_streamer_tag := soup.find("span", {"data-testid": "qsp-price"}):
text = specific_fin_streamer_tag.get_text()
return text
return "No <fin-streamer> tag with the specified data-test attribute found."
return "No <fin-streamer> tag with the specified data-testid attribute found."


# Search for the symbol at https://finance.yahoo.com/lookup
Expand Down
Loading