]> git.phdru.name Git - bookmarks_db.git/commitdiff
Refactor(Robots/bkmk_rcurlcffi) : Use `curl_cffi.requests.Session`
authorOleg Broytman <phd@phdru.name>
Thu, 6 Mar 2025 19:58:03 +0000 (22:58 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 6 Mar 2025 20:06:40 +0000 (23:06 +0300)
Robots/bkmk_rcurlcffi.py

index 4d863a5e92b15362168c94e36aad0b6f3af5d6c4..bd89c462444e303e584604eab5b4beb543997968 100644 (file)
@@ -1,4 +1,4 @@
-"""Robot based on curl-cffi
+"""Robot based on curl-cffi.request.Session()
 
 This file is a part of Bookmarks database and Internet robot.
 
@@ -11,7 +11,7 @@ __license__ = "GNU GPL"
 __all__ = ['robot_curlcffi']
 
 
-from curl_cffi import requests
+from curl_cffi.requests import Session
 import curl_cffi
 
 from Robots.base import robot_base
@@ -37,10 +37,11 @@ class robot_curlcffi(robot_base):
 
         error = r = None
         try:
-            r = requests.get(url, headers=req_headers,
-                             timeout=self.timeout,
-                             allow_redirects=False, proxies=proxies,
-                             verify=False, impersonate='firefox133')
+            with Session() as s:
+                r = s.get(url, headers=req_headers,
+                          timeout=self.timeout,
+                          allow_redirects=False, proxies=proxies,
+                          verify=False, impersonate='firefox133')
         except curl_cffi.CurlError as e:
             error = str(e)
             return error, None, None, None