From 7e994d765c3193ed4daadbccd008d4819373d9b5 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 6 Mar 2025 20:09:58 +0300 Subject: [PATCH] Feat(Robots/bkmk_rhttpx): Use `httpx.Client()` --- Robots/bkmk_rhttpx.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Robots/bkmk_rhttpx.py b/Robots/bkmk_rhttpx.py index b1451c6..977342d 100644 --- a/Robots/bkmk_rhttpx.py +++ b/Robots/bkmk_rhttpx.py @@ -35,12 +35,11 @@ class robot_httpx(robot_base): else: proxy = None - error = r = None try: - r = httpx.get(url, headers=req_headers, + with httpx.Client(proxy=proxy, verify=False) as c: + r = c.get(url, headers=req_headers, timeout=httpx.Timeout(self.timeout), - follow_redirects=False, proxy=proxy, - verify=False) + follow_redirects=False) except (httpx.RequestError, socksio.ProtocolError) as e: error = str(e) return error, None, None, None -- 2.39.5