Skip to content

Commit 260dc8f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 67ef397 commit 260dc8f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

web_programming/covid_stats_via_xpath.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
# ]
1212
# ///
1313

14-
1514
from typing import NamedTuple
1615
import httpx
1716
from lxml import html
1817

18+
1919
class CovidData(NamedTuple):
2020
cases: str
2121
deaths: str
2222
recovered: str
2323

24+
2425
def 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+
4650
if __name__ == "__main__":
4751
fmt = """Total COVID-19 cases in the world: {}
4852
Total deaths due to COVID-19 in the world: {}

0 commit comments

Comments
 (0)