File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 15
15
def stock_price (symbol : str = "AAPL" ) -> str :
16
16
"""
17
17
>>> stock_price("EEEE")
18
- 'No <fin-streamer> tag with the specified data-test attribute found. '
18
+ '- '
19
19
>>> isinstance(float(stock_price("GOOG")),float)
20
20
True
21
21
"""
@@ -24,12 +24,10 @@ def stock_price(symbol: str = "AAPL") -> str:
24
24
url , headers = {"USER-AGENT" : "Mozilla/5.0" }, timeout = 10
25
25
).text
26
26
soup = BeautifulSoup (yahoo_finance_source , "html.parser" )
27
- specific_fin_streamer_tag = soup .find ("fin-streamer" , {"data-testid" : "qsp-price" })
28
27
29
- if specific_fin_streamer_tag :
30
- text = specific_fin_streamer_tag .get_text ()
31
- return text
32
- return "No <fin-streamer> tag with the specified data-test attribute found."
28
+ if specific_fin_streamer_tag := soup .find ("span" , {"data-testid" : "qsp-price" }):
29
+ return specific_fin_streamer_tag .get_text ()
30
+ return "No <fin-streamer> tag with the specified data-testid attribute found."
33
31
34
32
35
33
# Search for the symbol at https://finance.yahoo.com/lookup
You can’t perform that action at this time.
0 commit comments