googlesearch icon indicating copy to clipboard operation
googlesearch copied to clipboard

Fix Incorrect Proxy Setting Usage in Request Module

Open t-tani opened this issue 1 year ago • 0 comments

Description

The current implementation of the proxy setting in the search function does not handle proxies correctly. Specifically, if a proxy is set with the format http://proxy_host:port, it does not handle https requests to proxy, which is required for Google search.

Related Issues

#73

Solution

This PR updates the proxy setting logic to correctly configure the proxy for both http and https protocols when the proxy URL starts with http:// or https://. This ensures that https requests are properly routed through the proxy even when the proxy URL is specified with http://.

Changes Made

Updated the proxy setting logic to configure proxies for both http and https protocols properly.

Old Code

if proxy:
    if proxy.startswith("https"):
        proxies = {"https": proxy}
    else:
        proxies = {"http": proxy}

New Code

if proxy.startswith("http://") or proxy.startswith("https://"):
    proxies = {
        "https": proxy,
        "http": proxy
    }

t-tani avatar Jun 17 '24 02:06 t-tani