1- from urllib3 .util import ssl_
21from requests import Session
3- from requests .adapters import HTTPAdapter
42from requests_cache import CacheMixin
53from requests_ratelimiter import LimiterMixin
64
@@ -10,30 +8,4 @@ class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
108 LimiterSession and CachedSession.
119
1210 See: See: https://requests-cache.readthedocs.io/en/stable/user_guide/compatibility.html#requests-ratelimiter
13- """
14-
15- class CloudflareBypassHTTPAdapter (HTTPAdapter ):
16- """
17- A TransportAdapter that forces TLSv1.3 in Requests, so that Cloudflare doesn't flag us.
18-
19- Source: https://lukasa.co.uk/2017/02/Configuring_TLS_With_Requests/
20- """
21-
22- def init_patched_ssl_context (self ):
23- context = ssl_ .create_urllib3_context ()
24- context .load_default_certs ()
25- # Only available in Python 3.7
26- if hasattr (ssl_ , "TLSVersion" ):
27- context .minimum_version = ssl_ .TLSVersion .TLSv1_3
28- else :
29- context .options |= ssl_ .OP_NO_TLSv1_2
30-
31- return context
32-
33- def init_poolmanager (self , * args , ** kwargs ):
34- kwargs ['ssl_context' ] = self .init_patched_ssl_context ()
35- return super (CloudflareBypassHTTPAdapter , self ).init_poolmanager (* args , ** kwargs )
36-
37- def proxy_manager_for (self , * args , ** kwargs ):
38- kwargs ['ssl_context' ] = self .init_patched_ssl_context ()
39- return super (CloudflareBypassHTTPAdapter , self ).proxy_manager_for (* args , ** kwargs )
11+ """
0 commit comments