From a09eeed7c2d595cecafd3f6371e55ab4577bd07c Mon Sep 17 00:00:00 2001 From: erick-gege Date: Mon, 9 Mar 2026 21:13:50 -0500 Subject: [PATCH 1/4] Add proxy support --- estela_requests/proxy.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 estela_requests/proxy.py diff --git a/estela_requests/proxy.py b/estela_requests/proxy.py new file mode 100644 index 0000000..00ce32e --- /dev/null +++ b/estela_requests/proxy.py @@ -0,0 +1,32 @@ +import os +import logging + +logger = logging.getLogger(__name__) + +TUNNEL_HOST = "127.0.0.1" +TUNNEL_PORT = "8888" + + +def estela_proxy(): + if os.environ.get("ESTELA_PROXIES_ENABLED"): + logger.debug("[proxy] Proxy active at %s:%s", TUNNEL_HOST, TUNNEL_PORT) + return f"{TUNNEL_HOST}:{TUNNEL_PORT}" + return None + + +def estela_driver_kwargs(): + """ + Returns the kwargs needed to configure a SeleniumBase Driver with proxy support. + If proxy is disabled, returns an empty dict so the Driver works normally. + + Usage: + from estela_requests.proxy import estela_driver_kwargs + driver = Driver(browser="chrome", uc=True, **estela_driver_kwargs()) + """ + proxy = estela_proxy() + if proxy: + return { + "proxy": proxy, + "chromium_arg": "--ignore-certificate-errors --ignore-ssl-errors", + } + return {} \ No newline at end of file From 202836a3af8fcb10f550b20df42cec63601f79c4 Mon Sep 17 00:00:00 2001 From: erick-gege Date: Mon, 9 Mar 2026 21:18:12 -0500 Subject: [PATCH 2/4] lint --- estela_requests/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/estela_requests/proxy.py b/estela_requests/proxy.py index 00ce32e..883c1e5 100644 --- a/estela_requests/proxy.py +++ b/estela_requests/proxy.py @@ -29,4 +29,4 @@ def estela_driver_kwargs(): "proxy": proxy, "chromium_arg": "--ignore-certificate-errors --ignore-ssl-errors", } - return {} \ No newline at end of file + return {} From 53739c34be3be7b00cef316e7457991406dbd662 Mon Sep 17 00:00:00 2001 From: erick-gege Date: Mon, 9 Mar 2026 21:22:12 -0500 Subject: [PATCH 3/4] fix order --- estela_requests/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/estela_requests/proxy.py b/estela_requests/proxy.py index 883c1e5..fc68690 100644 --- a/estela_requests/proxy.py +++ b/estela_requests/proxy.py @@ -1,5 +1,5 @@ -import os import logging +import os logger = logging.getLogger(__name__) From b7b6a23699871fbbf03c1dafd8e8d32a8d72959d Mon Sep 17 00:00:00 2001 From: Joaquin Date: Tue, 10 Mar 2026 13:27:09 -0500 Subject: [PATCH 4/4] Add estela_proxies() for requests-based spiders, fix chromium_arg - Add estela_proxies() returning requests-compatible dict with upstream credentials - Fix chromium_arg: remove invalid --ignore-ssl-errors flag Co-Authored-By: Claude Opus 4.6 --- estela_requests/proxy.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/estela_requests/proxy.py b/estela_requests/proxy.py index fc68690..d540a55 100644 --- a/estela_requests/proxy.py +++ b/estela_requests/proxy.py @@ -14,6 +14,30 @@ def estela_proxy(): return None +def estela_proxies(): + """ + Returns a requests-compatible proxies dict with upstream proxy credentials. + For use with requests.Session (no mitmproxy tunnel needed). + Returns an empty dict when proxy is disabled. + + Usage: + from estela_requests.proxy import estela_proxies + session = requests.Session() + session.proxies = estela_proxies() + """ + if not os.environ.get("ESTELA_PROXIES_ENABLED"): + return {} + user = os.environ.get("ESTELA_PROXY_USER", "") + password = os.environ.get("ESTELA_PROXY_PASS", "") + host = os.environ.get("ESTELA_PROXY_URL", "") + port = os.environ.get("ESTELA_PROXY_PORT", "") + if not all([user, password, host]): + logger.warning("[proxy] Incomplete proxy variables.") + return {} + proxy_url = f"http://{user}:{password}@{host}:{port}" + return {"http": proxy_url, "https": proxy_url} + + def estela_driver_kwargs(): """ Returns the kwargs needed to configure a SeleniumBase Driver with proxy support. @@ -27,6 +51,6 @@ def estela_driver_kwargs(): if proxy: return { "proxy": proxy, - "chromium_arg": "--ignore-certificate-errors --ignore-ssl-errors", + "chromium_arg": "--ignore-certificate-errors", } return {}