File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1212# ]
1313# ///
1414
15-
1615from typing import NamedTuple
1716
1817import httpx
1918from lxml import html
2019
20+
2121class CovidData (NamedTuple ):
2222 cases : str
2323 deaths : str
2424 recovered : str
2525
26+
2627def covid_stats (
2728 url : str = (
2829 "https://web.archive.org/web/20250825095350/"
@@ -34,7 +35,9 @@ def covid_stats(
3435 response = httpx .get (url , timeout = 10 )
3536 response .raise_for_status ()
3637 except httpx .TimeoutException :
37- print ("Request timed out. Please check your network connection or try again later." )
38+ print (
39+ "Request timed out. Please check your network connection or try again later."
40+ )
3841 return CovidData ("N/A" , "N/A" , "N/A" )
3942 except httpx .HTTPStatusError as e :
4043 print (f"HTTP error occurred: { e } " )
@@ -45,10 +48,11 @@ def covid_stats(
4548 return CovidData ("N/A" , "N/A" , "N/A" )
4649 return CovidData (* data )
4750
51+
4852if __name__ == "__main__" :
4953 fmt = (
5054 "Total COVID-19 cases in the world: {}\n "
5155 "Total deaths due to COVID-19 in the world: {}\n "
5256 "Total COVID-19 patients recovered in the world: {}"
5357 )
54- print (fmt .format (* covid_stats ()))
58+ print (fmt .format (* covid_stats ()))
You can’t perform that action at this time.
0 commit comments