@@ -183,11 +183,11 @@ def _use_proxy(self, http: str, https: str = None) -> bool:
183183 :returns: whether or not the proxy was set up successfully
184184 :rtype: {bool}
185185 """
186- if https is None :
187- https = http
188186 if http [:4 ] != "http" :
189187 http = "http://" + http
190- if https [:5 ] != "https" :
188+ if https is None :
189+ https = http
190+ elif https [:5 ] != "https" :
191191 https = "https://" + https
192192
193193 proxies = {'http://' : http , 'https://' : https }
@@ -205,7 +205,7 @@ def _use_proxy(self, http: str, https: str = None) -> bool:
205205
206206 if self ._proxy_works :
207207 self ._proxies = proxies
208- self ._new_session ()
208+ self ._new_session (proxies = proxies )
209209
210210 return self ._proxy_works
211211
@@ -444,8 +444,9 @@ def _handle_captcha2(self, url):
444444
445445 return self ._session
446446
447- def _new_session (self ):
447+ def _new_session (self , ** kwargs ):
448448 init_kwargs = {}
449+ init_kwargs .update (kwargs )
449450 proxies = {}
450451 if self ._session :
451452 proxies = self ._proxies
@@ -612,8 +613,9 @@ def ScraperAPI(self, API_KEY, country_code=None, premium=False, render=False):
612613 for _ in range (3 ):
613614 proxy_works = self ._use_proxy (http = f'{ prefix } :{ API_KEY } @proxy-server.scraperapi.com:8001' )
614615 if proxy_works :
616+ proxies = {'http://' : f"http://scraperapi:{ API_KEY } @proxy-server.scraperapi.com:8001" ,}
615617 self .logger .info ("ScraperAPI proxy setup successfully" )
616- self ._session . verify = False
618+ self ._new_session ( verify = False , proxies = proxies )
617619 return proxy_works
618620
619621 if (r ["requestCount" ] >= r ["requestLimit" ]):
0 commit comments