
    4ROf[                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
Z
d dlZd dlZdZ G d de      Z G d	 d
e      Zy)    N)PoolManager)ssl_)HTTPAdapter)RetryzECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384: ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:AES256-SHAc                   &     e Zd Zd fd	Zd Z xZS )
TlsAdapterc                 F    || _         t        t        |   di |dddd y )N      F)pool_maxsizemax_retries
pool_block )ssl_optionssuperr   __init__)selfr   kwargs	__class__s      -/var/www/premiumrankchecker/RequestManager.pyr   zTlsAdapter.__init__   s.    &j$( 	
	
#$!	
    c                     t        j                  t        t        j                  | j
                        }t        |d|i|| _        y )N)ciphers	cert_reqsoptionsssl_context)r   create_urllib3_contextCIPHERSsslCERT_REQUIREDr   r   poolmanager)r   	pool_argspool_kwargsctxs       r   init_poolmanagerzTlsAdapter.init_poolmanager   s>    ))s'8'8$BRBR
 '	RsRkRr   r   )__name__
__module____qualname__r   r%   __classcell__)r   s   @r   r   r      s    
Sr   r   c                       e Zd Zd Zd Zddej                  fdZd Zd Z	d Z
d Zdej                  fd	Zdej                  fd
Zy)RequestManagerc                 p    t        t        j                  t        j                  z        | _        || _        y N)r   r   OP_NO_TLSv1OP_NO_TLSv1_1adapterget_alternator)r   r2   s     r   r   zRequestManager.__init__   s%    !#//C4E4E"EF,r   c                 f    t        j                         }|j                  d| j                         |S )Nzhttps://)requestsSessionmountr1   )r   ss     r   getNewSessionzRequestManager.getNewSession!   s'    	
DLL)r   returnc                     |dk(  r| j                  |      S |dk(  r| j                  |      S |dk(  r| j                  |      S |dk(  r| j                  |      S y )Nr         r   )getRequestProxyCheapgetRequestProxyScrapegetRequestIPRoyal)r   urlr2   s      r   
getRequestzRequestManager.getRequest&   sk    Q,,S11Q--c22Q))#..Q--c22 r   c                 .    | j                  |      }||S y r.   )getRequestWebshare)r   r@   webshare_responses      r   getRequestWithoutAWSz#RequestManager.getRequestWithoutAWS0   s"     33C8($$r   c                 <   t        dt        |      z   dz          | j                         }d}|j                  j	                  ||d       	 |j                  |d      }|j                  dk7  ry |S # t        $ r!}t        dt        |      z          Y d }~y d }~ww xY w)	NTrying to get: z with IPRoyalzLhttp://alex133769:mArgare1he_region-europe_streaming-1@geo.iproyal.com:12321httpshttp
   timeout   z Exception in getRequestIPRoyal: printstrr8   proxiesupdategetstatus_code	Exception)r   r@   r7   iproyal_proxyresponsees         r   r?   z RequestManager.getRequestIPRoyal6   s    #c(*_<= f			=-HI	?uuS"u-H##s*O 	?4s1v=>>	?   "A1 /A1 1	B:BBc                 <   t        dt        |      z   dz          | j                         }d}|j                  j	                  ||d       	 |j                  |d      }|j                  dk7  ry |S # t        $ r!}t        dt        |      z          Y d }~y d }~ww xY w)	NrG   z with ProxyCheapz4http://bkxwrzbp:25vLo8CZESG3alvb@209.38.175.10:31112rH   rK   rL   rN   z#Exception in getRequestProxyCheap: rO   )r   r@   r7   proxycheap_proxyrX   rY   s         r   r=   z#RequestManager.getRequestProxyCheapD   s    #c(*-??@ Q			#3=MNO	BuuS"u-H##s*O 	B7#a&@AA	BrZ   c                 <   t        dt        |      z   dz          | j                         }d}|j                  j	                  ||d       	 |j                  |d      }|j                  dk7  ry |S # t        $ r!}t        dt        |      z          Y d }~y d }~ww xY w)	NrG   z with Proxyscrapez>http://che4pvco7u1h1db:bvt6yy7wrahb637@rp.proxyscrape.com:6060rH   rK   rL   rN   z$Exception in getRequestProxyScrape: rO   )r   r@   r7   proxyscrape_proxyrX   rY   s         r   r>   z$RequestManager.getRequestProxyScrapeR   s    #c(*-@@A \			#4>OPQ	CuuS"u-H##s*O 	C83q6ABB	CrZ   c                 H    | j                         }|j                  |      }|S r.   )r8   rT   )r   r@   r7   rs       r   getRequestNakedzRequestManager.getRequestNakeda   s"     EE#Jr   c                 L    | j                         }|j                  ||      }|S )N)json)r8   post)r   r@   _jsonr7   r`   s        r   postRequestNakedzRequestManager.postRequestNakedf   s'     FF3UF#r   Nr&   )r'   r(   r)   r   r8   r4   ResponserA   rE   r?   r=   r>   ra   rf   r   r   r   r,   r,      sV    -
383D3D 3h&7&7 
h.?.? r   r,   )r4   r   %requests.packages.urllib3.poolmanagerr   requests.packages.urllib3.utilr   requests.adaptersr   $requests.packages.urllib3.util.retryr   timerc   randomr   r   objectr,   r   r   r   <module>ro      sD     
 = / ) 6    xS SMV Mr   