Skip to content

Commit 381c27f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 55fadb7 commit 381c27f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

web_programming/covid_stats_via_xpath.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
# ]
1313
# ///
1414

15-
1615
from typing import NamedTuple
1716

1817
import httpx
1918
from lxml import html
2019

20+
2121
class CovidData(NamedTuple):
2222
cases: str
2323
deaths: str
2424
recovered: str
2525

26+
2627
def 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+
4852
if __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()))

0 commit comments

Comments
 (0)