From 4ac753a24830a304a82907fa0f583d5788adda6c Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Sun, 12 Jan 2025 03:38:46 +0300 Subject: [PATCH 1/5] Empty commit From b579604d6d7f61f9bb2f5953817642c7079191c5 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Sun, 12 Jan 2025 04:07:10 +0300 Subject: [PATCH 2/5] Fix --- web_programming/current_stock_price.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_programming/current_stock_price.py b/web_programming/current_stock_price.py index d0a65e9aac84..45c868ff7baa 100644 --- a/web_programming/current_stock_price.py +++ b/web_programming/current_stock_price.py @@ -24,12 +24,12 @@ 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"}) + specific_fin_streamer_tag = soup.find("span", {"data-testid": "qsp-price"}) if specific_fin_streamer_tag: text = specific_fin_streamer_tag.get_text() return text - return "No tag with the specified data-test attribute found." + return "No tag with the specified data-testid attribute found." # Search for the symbol at https://finance.yahoo.com/lookup From 598431daf8413dfdf676f94c2e649b31682554ae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 01:07:36 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- web_programming/current_stock_price.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web_programming/current_stock_price.py b/web_programming/current_stock_price.py index 45c868ff7baa..baaefa23758c 100644 --- a/web_programming/current_stock_price.py +++ b/web_programming/current_stock_price.py @@ -24,9 +24,8 @@ 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("span", {"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 tag with the specified data-testid attribute found." From fd1f93e194567a4fe8a6000257677cee2ed90876 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Sun, 12 Jan 2025 04:10:08 +0300 Subject: [PATCH 4/5] Fix --- web_programming/current_stock_price.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/current_stock_price.py b/web_programming/current_stock_price.py index 45c868ff7baa..3ef5be18d8b8 100644 --- a/web_programming/current_stock_price.py +++ b/web_programming/current_stock_price.py @@ -15,7 +15,7 @@ def stock_price(symbol: str = "AAPL") -> str: """ >>> stock_price("EEEE") - '-' + '- ' >>> isinstance(float(stock_price("GOOG")),float) True """ From 8d9fa8184362aa67e2b3b892a3c4b18974000d9a Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jan 2025 21:46:17 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- web_programming/current_stock_price.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web_programming/current_stock_price.py b/web_programming/current_stock_price.py index a18b1952cfaa..573e1f575c8e 100644 --- a/web_programming/current_stock_price.py +++ b/web_programming/current_stock_price.py @@ -26,8 +26,7 @@ def stock_price(symbol: str = "AAPL") -> str: soup = BeautifulSoup(yahoo_finance_source, "html.parser") if specific_fin_streamer_tag := soup.find("span", {"data-testid": "qsp-price"}): - text = specific_fin_streamer_tag.get_text() - return text + return specific_fin_streamer_tag.get_text() return "No tag with the specified data-testid attribute found."