11import random
22
3+ from curl_cffi import CurlOpt
34from curl_cffi .requests import AsyncSession
45
56
@@ -15,16 +16,18 @@ def __init__(self, proxy=None, timeout=30, verify=True, impersonate='safari15_3'
1516 # self.ja3 = ""
1617 # self.akamai = ""
1718 # ja3=self.ja3, akamai=self.akamai
18- self .session = AsyncSession (proxies = self .proxies , timeout = self .timeout , impersonate = self .impersonate , verify = self .verify )
19+ curl_options = {
20+ CurlOpt .LOW_SPEED_LIMIT : 1 ,
21+ CurlOpt .LOW_SPEED_TIME : 30
22+ }
23+ self .session = AsyncSession (proxies = self .proxies , timeout = self .timeout , impersonate = self .impersonate , verify = self .verify , curl_options = curl_options )
1924
2025 async def post (self , * args , ** kwargs ):
2126 r = await self .session .post (* args , ** kwargs )
2227 return r
2328
2429 async def post_stream (self , * args , ** kwargs ):
25- self .session .timeout = 600
2630 r = await self .session .post (* args , ** kwargs )
27- self .session .timeout = 30
2831 return r
2932
3033 async def get (self , * args , ** kwargs ):
@@ -46,9 +49,3 @@ async def close(self):
4649 del self .session
4750 except Exception :
4851 pass
49- if hasattr (self , 'session2' ):
50- try :
51- await self .session2 .close ()
52- del self .session2
53- except Exception :
54- pass
0 commit comments