Skip to content

Commit 668e893

Browse files
authored
Replace httpx with httpx2 for HTTP requests
1 parent 36da47d commit 668e893

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎web_programming/covid_stats_via_xpath.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def covid_stats(
3737
) -> CovidData:
3838
xpath_str = '//div[@class = "maincounter-number"]/span/text()'
3939
try:
40-
response = httpx.get(url, timeout=10).raise_for_status()
41-
except httpx.TimeoutException:
40+
response = httpx2.get(url, timeout=10).raise_for_status()
41+
except httpx2.TimeoutException:
4242
logging.error(
4343
"Request timed out. Please check your network connection "
4444
"or try again later."
4545
)
4646
return CovidData("N/A", "N/A", "N/A")
47-
except httpx.HTTPStatusError as e:
47+
except httpx2.HTTPStatusError as e:
4848
logging.error(f"HTTP error occurred: {e}")
4949
return CovidData("N/A", "N/A", "N/A")
5050
data: list[str] = html.fromstring(response.content).xpath(xpath_str)

0 commit comments

Comments
 (0)