File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1111# ]
1212# ///
1313
14-
1514from typing import NamedTuple
1615import httpx
1716from lxml import html
1817
18+
1919class CovidData (NamedTuple ):
2020 cases : str
2121 deaths : str
2222 recovered : str
2323
24+
2425def covid_stats (
2526 url : str = "https://web.archive.org/web/20250825095350/https://www.worldometers.info/coronavirus/" ,
2627) -> CovidData :
@@ -29,7 +30,9 @@ def covid_stats(
2930 response = httpx .get (url , timeout = 10 )
3031 response .raise_for_status ()
3132 except httpx .TimeoutException :
32- print ("Request timed out. Please check your network connection or try again later." )
33+ print (
34+ "Request timed out. Please check your network connection or try again later."
35+ )
3336 return CovidData ("N/A" , "N/A" , "N/A" )
3437 except httpx .HTTPStatusError as e :
3538 print (f"HTTP error occurred: { e } " )
@@ -43,6 +46,7 @@ def covid_stats(
4346 return CovidData ("N/A" , "N/A" , "N/A" )
4447 return CovidData (* data )
4548
49+
4650if __name__ == "__main__" :
4751 fmt = """Total COVID-19 cases in the world: {}
4852Total deaths due to COVID-19 in the world: {}
You can’t perform that action at this time.
0 commit comments