Skip to content

Commit aa795ec

Browse files
committed
Set proxy correctly for ScraperAPI
Fixes #477.
1 parent dbcc7b4 commit aa795ec

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

scholarly/_proxy_generator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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}
@@ -613,8 +613,9 @@ def ScraperAPI(self, API_KEY, country_code=None, premium=False, render=False):
613613
for _ in range(3):
614614
proxy_works = self._use_proxy(http=f'{prefix}:{API_KEY}@proxy-server.scraperapi.com:8001')
615615
if proxy_works:
616+
proxies = {'http://': f"http://scraperapi:{API_KEY}@proxy-server.scraperapi.com:8001",}
616617
self.logger.info("ScraperAPI proxy setup successfully")
617-
self._session.verify = False
618+
self._new_session(verify=False, proxies=proxies)
618619
return proxy_works
619620

620621
if (r["requestCount"] >= r["requestLimit"]):

0 commit comments

Comments
 (0)