From df0e844223a1d3139d9b196ce20095450482ee32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:19:45 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- web_programming/current_stock_price.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_programming/current_stock_price.py b/web_programming/current_stock_price.py index dfce457e1..7fd40efea 100644 --- a/web_programming/current_stock_price.py +++ b/web_programming/current_stock_price.py @@ -4,9 +4,9 @@ from bs4 import BeautifulSoup def stock_price(symbol: str = "AAPL") -> str: url = f"https://finance.yahoo.com/quote/{symbol}?p={symbol}" - yahoo_finance_source = requests.get(url,headers={'USER-AGENT': "Mozilla/5.0"}).text + yahoo_finance_source = requests.get(url, headers={"USER-AGENT": "Mozilla/5.0"}).text soup = BeautifulSoup(yahoo_finance_source, "html.parser") - specific_fin_streamer_tag = soup.find('fin-streamer', {'data-test': 'qsp-price'}) + specific_fin_streamer_tag = soup.find("fin-streamer", {"data-test": "qsp-price"}) if specific_fin_streamer_tag: text = specific_fin_streamer_tag.get_text() @@ -15,6 +15,7 @@ def stock_price(symbol: str = "AAPL") -> str: print("No tag with the specified data-test attribute found.") return "Not Found" + # Search for the symbol at https://finance.yahoo.com/lookup if __name__ == "__main__": for symbol in "AAPL AMZN IBM GOOG MSFT ORCL".split():