Jul-14-2023, 04:19 PM
Problem solved!!
def main_request(data, proxy='', type_of_proxy='socks5', user_agent='Mozilla/5.0 (Linux; arm; Android 13; PEPM00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.141 YaBrowser/22.3.6.61.00 SA/3 Mobile Safari/537.36'): class TimeoutHTTPAdapter(HTTPAdapter): def __init__(self, *args, **kwargs): if "timeout" in kwargs: self.timeout = kwargs["timeout"] del kwargs["timeout"] super().__init__(*args, **kwargs) def send(self, request, **kwargs): timeout = kwargs.get("timeout") if timeout is None and hasattr(self, 'timeout'): kwargs["timeout"] = self.timeout return super().send(request, **kwargs) s = requests.Session() s.mount('http://', TimeoutHTTPAdapter(timeout=5)) # 5 seconds s.mount('https://', TimeoutHTTPAdapter(timeout=5)) proxies = { 'http': f'{type_of_proxy}://{proxy}', 'https': f'{type_of_proxy}://{proxy}' } page_login = s.post('https://my-site.com', data=data_1.encode('utf-8'), verify=False, proxies=proxies, headers=headers_dic,timeout=timeout_request) print(main_request(data='1',proxy='login:[email protected]:16000',type_of_proxy='http'))